mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-12 22:47:06 +00:00
Allow datetime offsets that look like "-0400"
This commit is contained in:
parent
7f73a2000d
commit
fa6ace73a4
1 changed files with 12 additions and 5 deletions
17
src/date.rs
17
src/date.rs
|
@ -160,11 +160,18 @@ pub fn parse_date<I>(
|
|||
DateToken::Plus => 1, DateToken::Dash => -1, _ => panic!()
|
||||
};
|
||||
let h = take!(DateToken::Number(s, None), s);
|
||||
let h = i32::from_str_radix(&*h, 10).unwrap();
|
||||
take!(DateToken::Colon);
|
||||
let m = take!(DateToken::Number(s, None), s);
|
||||
let m = i32::from_str_radix(&*m, 10).unwrap();
|
||||
out.offset = Some(s * (h*3600 + m*60));
|
||||
if h.len() == 4 {
|
||||
let h = i32::from_str_radix(&*h, 10).unwrap();
|
||||
let m = h % 100;
|
||||
let h = h / 100;
|
||||
out.offset = Some(s * (h*3600 + m*60));
|
||||
} else {
|
||||
let h = i32::from_str_radix(&*h, 10).unwrap();
|
||||
take!(DateToken::Colon);
|
||||
let m = take!(DateToken::Number(s, None), s);
|
||||
let m = i32::from_str_radix(&*m, 10).unwrap();
|
||||
out.offset = Some(s * (h*3600 + m*60));
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
"monthname" => match tok {
|
||||
|
|
Loading…
Reference in a new issue