Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNU coreutils date-like time zone formatting #759

Merged
merged 10 commits into from
Aug 17, 2022
35 changes: 11 additions & 24 deletions src/format/strftime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,30 +403,17 @@ impl<'a> Iterator for StrftimeItems<'a> {
}
'+' => fix!(RFC3339),
':' => {
let mut num_colon = 1;

let result = loop {
match next!() {
':' => {
num_colon += 1;
}
'z' => {
break Ok(());
}
_ => {
break Err(Item::Error);
}
}
};

match result {
Ok(_) => match num_colon {
1 => fix!(TimezoneOffsetColon),
2 => fix!(TimezoneOffsetDoubleColon),
3 => fix!(TimezoneOffsetTripleColon),
_ => Item::Error,
},
Err(e) => e,
if self.remainder.starts_with("::z") {
self.remainder = &self.remainder[3..];
fix!(TimezoneOffsetTripleColon)
} else if self.remainder.starts_with(":z") {
self.remainder = &self.remainder[2..];
fix!(TimezoneOffsetDoubleColon)
} else if self.remainder.starts_with('z') {
self.remainder = &self.remainder[1..];
fix!(TimezoneOffsetColon)
} else {
Item::Error
}
}
'.' => match next!() {
Expand Down