-
Notifications
You must be signed in to change notification settings - Fork 40
fix(offset): correct ADT, AST, BST, GST and SST to GNU's values #325
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -300,7 +300,7 @@ fn timezone_name_to_offset(input: &str) -> ModalResult<Offset> { | |
| "ut" => Ok("+0"), | ||
| "u" => Ok("-8"), | ||
| "t" => Ok("-7"), | ||
| "sst" => Ok("-11"), | ||
| "sst" => Ok("-12"), | ||
| "sgt" => Ok("+8"), | ||
| "sast" => Ok("+2"), | ||
| "s" => Ok("-6"), | ||
|
|
@@ -331,7 +331,7 @@ fn timezone_name_to_offset(input: &str) -> ModalResult<Offset> { | |
| "i" => Ok("+9"), | ||
| "hst" => Ok("-10"), | ||
| "h" => Ok("+8"), | ||
| "gst" => Ok("+4"), | ||
| "gst" => Ok("+10"), | ||
| "gmt" => Ok("+0"), | ||
| "g" => Ok("+7"), | ||
| "f" => Ok("+6"), | ||
|
|
@@ -350,15 +350,15 @@ fn timezone_name_to_offset(input: &str) -> ModalResult<Offset> { | |
| "cdt" => Ok("-5"), | ||
| "cat" => Ok("+2"), | ||
| "c" => Ok("+3"), | ||
| "bst" => Ok("+6"), | ||
| "bst" => Ok("+1"), | ||
| "brt" => Ok("-3"), | ||
| "brst" => Ok("-2"), | ||
| "b" => Ok("+2"), | ||
| "ast" => Ok("-3"), | ||
| "ast" => Ok("-4"), | ||
| "art" => Ok("-3"), | ||
| "akst" => Ok("-9"), | ||
| "akdt" => Ok("-8"), | ||
| "adt" => Ok("+4"), | ||
| "adt" => Ok("-3"), | ||
| "a" => Ok("+1"), | ||
| _ => Err(ErrMode::Backtrack(ContextError::new())), | ||
| }?; | ||
|
|
@@ -457,6 +457,12 @@ mod tests { | |
| ("mesz", off(false, 2, 0)), | ||
| ("mest", off(false, 2, 0)), | ||
| ("kst", off(false, 9, 0)), | ||
| // Corrected to the offsets GNU date assigns these abbreviations. | ||
| ("adt", off(true, 3, 0)), // Atlantic Daylight, was +4 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you please also add a test in tests/ going through parse_datetime, like "2026-06-15 12:00 BST"? that's the actual user-facing bug.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, done. Added the tests in tests/date.rs; they go through parse_datetime and cover all five abbreviations. |
||
| ("ast", off(true, 4, 0)), // Atlantic Standard, was -3 | ||
| ("bst", off(false, 1, 0)), // British Summer, was +6 | ||
| ("gst", off(false, 10, 0)), // Guam Standard, was +4 | ||
| ("sst", off(true, 12, 0)), // Samoa Standard, was -11 | ||
| ("z123", off(false, 0, 0)), // space separator can be ignored if immediately followed by digits (GNU date behavior) | ||
| ] { | ||
| let mut s = input; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gst +10 is Guam, but most people writing GST mean Gulf time (+4, Dubai), which is what we had. could you please explain why Guam wins here? it silently changes what users get today.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guam wins because it's the value GNU's own zone table assigns this token: GST is Guam Standard Time there, and
date --debug -d "2026-06-15 12:00 GST"on GNU coreutils 9.10 reportsparsed zone part: UTC+10. I take the point that most people writing GST mean Dubai, and this does silently change what they get today. The crate's documented scope is "we support the same subset as GNU date", so I went with GNU's reading. If you'd rather match common usage than GNU here, I'll put +4 back.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't quote GNU :(
the licenses are incompatible ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that :( you're right. I copied the table lines into two of the replies without thinking about the license side, and that was the wrong way to present the evidence. I've replaced them with the offsets stated plainly. The
date --debugoutput is still there, and nothing quoted remains.