diff options
| author | Edward Barnard | 2015-08-28 23:08:03 +0700 |
|---|---|---|
| committer | Edward Barnard | 2015-08-28 23:08:03 +0700 |
| commit | 361aa56bf877cd4210018c97ebaf6aa92ab4f608 (patch) | |
| tree | 82c6a47a8e9e597f221cc096c4f86d93fdae436e /src/lib.rs | |
| parent | 3e41485288049b1d7a9be60b84b4d78dcd400f39 (diff) | |
| download | rust-plist-361aa56bf877cd4210018c97ebaf6aa92ab4f608.tar.bz2 | |
Add date support via chrono
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -1,4 +1,5 @@ extern crate byteorder; +extern crate chrono; extern crate itertools; extern crate rustc_serialize; extern crate xml as xml_rs; @@ -9,6 +10,8 @@ mod builder; pub use builder::{Builder, BuilderError, BuilderResult}; +use chrono::{DateTime, UTC}; +use chrono::format::ParseError as ChronoParseError; use std::collections::HashMap; use std::io::{Read, Seek, SeekFrom}; use std::io::Error as IoError; @@ -19,7 +22,7 @@ pub enum Plist { Dictionary(HashMap<String, Plist>), Boolean(bool), Data(Vec<u8>), - Date(String), + Date(DateTime<UTC>), Real(f64), Integer(i64), String(String) @@ -38,7 +41,7 @@ pub enum PlistEvent { BooleanValue(bool), DataValue(Vec<u8>), - DateValue(String), + DateValue(DateTime<UTC>), IntegerValue(i64), RealValue(f64), StringValue(String), @@ -60,6 +63,12 @@ impl From<IoError> for ParserError { } } +impl From<ChronoParseError> for ParserError { + fn from(_: ChronoParseError) -> ParserError { + ParserError::InvalidData + } +} + pub enum StreamingParser<R: Read+Seek> { Xml(xml::StreamingParser<R>), Binary(binary::StreamingParser<R>) |
