Skip to content

Conversation

robertbastian
Copy link
Member

These should not format as "GMT+?", even if the offset is not set, and it shouldn't be possible to set a wrong offset.

The special-case code could also live in the specific format implementations in icu_datetime, but there it would be duplicated. It could also live in GetField<UtcOffset>, but I like putting it in TimeZoneInfo because then this is considered for equality of TimeZoneInfo, and by extension ZonedDateTime.

@gemini-code-assist
Copy link

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

@robertbastian robertbastian requested review from Manishearth and removed request for nekevss and zbraniecki October 9, 2025 11:29
#[allow(clippy::identity_op, clippy::neg_multiply)]
let offset = match self.0.as_str().as_bytes() {
b"utc" | b"gmt" => Some(UtcOffset::zero()),
b"utce01" => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: this is a lot of string search branches. the compiler might optimize it.

it may be possible to instead write this as a check for "utc", then a check for e or w, and then a numeric check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let someone else have the satisfaction of optimising this should that ever be needed

sffc
sffc previously requested changes Oct 9, 2025
Manishearth
Manishearth previously approved these changes Oct 9, 2025
Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest looks good

@robertbastian robertbastian requested a review from sffc October 10, 2025 09:33
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(please resolve the Etc and offset precedence; I consider it a bug)

@robertbastian robertbastian requested a review from sffc October 13, 2025 09:34
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(answered question about code example)

@robertbastian robertbastian requested a review from sffc October 13, 2025 18:49
@robertbastian robertbastian requested a review from sffc October 14, 2025 08:03
@sffc
Copy link
Member

sffc commented Oct 14, 2025

We could set the offset and ID to unknown if the offsets don't match in with_offset, such that we format as GMT+? in this error case.

Manishearth
Manishearth previously approved these changes Oct 14, 2025
@robertbastian robertbastian merged commit 2611c71 into unicode-org:main Oct 14, 2025
31 checks passed
@robertbastian robertbastian deleted the etc branch October 14, 2025 17:10
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a test for the mismatched offset behavior

@robertbastian
Copy link
Member Author

this PR tests that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants