aboutsummaryrefslogtreecommitdiffstats
path: root/src/xml
diff options
context:
space:
mode:
authorEdward Barnard2018-02-27 10:22:42 +0000
committerEdward Barnard2018-02-27 10:33:54 +0000
commitc91087906540c210bdb457b32fb976ce735b22f9 (patch)
tree1968d9710404fc8386f68c56f705d5d02774bbbb /src/xml
parent3ad6b78c4583b9ea8a801cd963d569eecbae144b (diff)
downloadrust-plist-c91087906540c210bdb457b32fb976ce735b22f9.tar.bz2
Stop exposing internal functions and chrono types in Date.
Diffstat (limited to 'src/xml')
-rw-r--r--src/xml/reader.rs4
-rw-r--r--src/xml/writer.rs5
2 files changed, 5 insertions, 4 deletions
diff --git a/src/xml/reader.rs b/src/xml/reader.rs
index e6b6953..66fd8f1 100644
--- a/src/xml/reader.rs
+++ b/src/xml/reader.rs
@@ -72,7 +72,7 @@ impl<R: Read> EventReader<R> {
}
"date" => {
return Some(self.read_content(|s| {
- Ok(PlistEvent::DateValue(Date::from_str(&s).map_err(|_| Error::InvalidData)?))
+ Ok(PlistEvent::DateValue(Date::from_rfc3339(&s)?))
}))
}
"integer" => {
@@ -176,7 +176,7 @@ mod tests {
StringValue("Data".to_owned()),
DataValue(vec![0, 0, 0, 190, 0, 0, 0, 3, 0, 0, 0, 30, 0, 0, 0]),
StringValue("Birthdate".to_owned()),
- DateValue(Utc.ymd(1981, 05, 16).and_hms(11, 32, 06).into()),
+ DateValue(Date::from_chrono(Utc.ymd(1981, 05, 16).and_hms(11, 32, 06))),
StringValue("Blank".to_owned()),
StringValue("".to_owned()),
EndDictionary];
diff --git a/src/xml/writer.rs b/src/xml/writer.rs
index 7048b32..ffb8aa4 100644
--- a/src/xml/writer.rs
+++ b/src/xml/writer.rs
@@ -166,7 +166,7 @@ impl<W: Write> PlistEventWriter for EventWriter<W> {
self.write_element_and_value("data", &base64_data)?;
}
PlistEvent::DateValue(ref value) => {
- self.write_element_and_value("date", &value.to_string())?
+ self.write_element_and_value("date", &value.to_rfc3339())?
}
PlistEvent::IntegerValue(ref value) => {
self.write_element_and_value("integer", &value.to_string())?
@@ -190,6 +190,7 @@ mod tests {
use chrono::{TimeZone, Utc};
use std::io::Cursor;
+ use Date;
use super::*;
#[test]
@@ -211,7 +212,7 @@ mod tests {
StringValue("Data".to_owned()),
DataValue(vec![0, 0, 0, 190, 0, 0, 0, 3, 0, 0, 0, 30, 0, 0, 0]),
StringValue("Birthdate".to_owned()),
- DateValue(Utc.ymd(1981, 05, 16).and_hms(11, 32, 06).into()),
+ DateValue(Date::from_chrono(Utc.ymd(1981, 05, 16).and_hms(11, 32, 06))),
EndDictionary];
let mut cursor = Cursor::new(Vec::new());