Skip to content

fix: use -0700 when formatting time #1388

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

Merged
merged 1 commit into from
Apr 28, 2025

Conversation

sudoforge
Copy link
Contributor

@sudoforge sudoforge commented Apr 28, 2025

+0200 is not a valid reference identifier for the time format string,
which requires a valid layout 0 using the reference time 01/02 03:04:05PM '06 -0700.

As the documentation notes:

It is a regrettable historic error that the date uses the American
convention of putting the numerical month before the day.

This, combined with -0700 being hardcoded into the layout requirements
is what likely led to the confusion that caused this issue. This change
is a fix for all Time.Format() calls, adjusting the time format in
place to use the correct tzdata. As a future potential improvement, we
should consider refactoring the format to use one of the constants in
the time package that are exported for the different predefined
formatting strings. This is not being done as part of this change
because the current formatting string used in these calls does not match
exactly with any of the predefined format strings.

... it isn't clear to me why this passes on CI. Using +0200 to
reference the timezone in the format string is invalid according to the
time package documentation.

Closes: #1387
Change-Id: Ifa198266c407524f7ef33ee33cf94ce9d0158f45

@sudoforge sudoforge enabled auto-merge April 28, 2025 23:36
@sudoforge sudoforge force-pushed the Ifa198266c407524f7ef33ee33cf94ce9d0158f45 branch 2 times, most recently from 07ea1eb to 9d52742 Compare April 28, 2025 23:42
@sudoforge sudoforge disabled auto-merge April 28, 2025 23:46
+0200 is not a valid reference identifier for the time format string,
which requires a valid layout [0] using the reference time `01/02
03:04:05PM '06 -0700`.

As the documentation notes:
> It is a regrettable historic error that the date uses the American
> convention of putting the numerical month before the day.

This, combined with `-0700` being hardcoded into the layout requirements
is what likely led to the confusion that caused this issue. This change
is a fix for all `Time.Format()` calls, adjusting the time format in
place to use the correct tzdata. As a future potential improvement, we
should consider refactoring the format to use one of the constants in
the time package that are exported for the different predefined
formatting strings. This is not being done as part of this change
because the current formatting string used in these calls does not match
exactly with any of the predefined format strings.

... it isn't clear to me why this passes on CI. Using `+0200` to
reference the timezone in the format string is invalid according to the
`time` package documentation.

[0]: https://pkg.go.dev/time#Layout

Closes: #1387
Change-Id: Ifa198266c407524f7ef33ee33cf94ce9d0158f45
@sudoforge sudoforge force-pushed the Ifa198266c407524f7ef33ee33cf94ce9d0158f45 branch from 9d52742 to 2b41071 Compare April 28, 2025 23:48
@sudoforge sudoforge enabled auto-merge April 28, 2025 23:48
@sudoforge sudoforge disabled auto-merge April 28, 2025 23:56
@sudoforge sudoforge merged commit edbd105 into master Apr 28, 2025
18 checks passed
@sudoforge sudoforge deleted the Ifa198266c407524f7ef33ee33cf94ce9d0158f45 branch April 28, 2025 23:56
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.

Invalid timezone (+2800) causing a test failure
1 participant