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

Change TZDEFRULES and TZDEFRULESTRING to "GMT". #868

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michaellenaghan
Copy link
Contributor

This is a companion to changing the default TZ value from "GST" to "GMT". The rationale is the same: it’s a less surprising "not defined" default.

For the curious, details follow.

===

TZDEFRULES is defined here and only used here, by localtime_tzparse().

In the original IANA code, the value of TZDEFRULES is "posixrules". "posixrules" was a POSIX fallback mechanism that tried to derive rules for one timezone from another. Foolish mortals! It was declared obsolete in the 2019b IANA release. (For more info about what it tried to do, see man 5 tzfile.)

If TZDEFRULES were set to NULL, localtime_tzparse() would fall back to TZDEFAULT, because of this:

if (! name) {
name = TZDEFAULT;

A recent pull request set TZDEFAULT to "GMT", so in a sense setting TZDEFRULES to NULL is another option. Setting it directly to "GMT", though, does a better job of making the intent obvious: if you can't find any rules, don't apply any rules.

TZDEFULESTRING is defined here and only used here, also in localtime_tzparse().

The value I've used, "GMT0", is the same value gmtload() passes to localtime_tzparse():

gmtload(struct state *const sp)
{
if (localtime_tzload(gmt, sp, true) != 0)
localtime_tzparse("GMT0", sp, NULL);
}

The format of the string is defined in Section 8.3 of the POSIX standard, available here.

I'm not sure I really wanted to know this much about how this stuff works. (How much do I really know…?) I'm not sure you really wanted to know this much about how this stuff works either. But here we are.

P.S. All of this is, in some sense, pointless; even redbean-2.2.com falls back to "GMT" if a timezone isn't found:

TZ="xxx" ./redbean-2.2.com -i -e "print(unix.localtime(unix.clock_gettime()))"
2023	7	26	17	32	38	0	3	206	0	GMT

This change really only affects deeper, darker corners of the code. "You're in a maze of twisty little passages…"

…om `,M3.2.0,M11.1.0` to `GMT0`.

This is a companion to changing the default TZ value from GST to GMT. The rationale is the same: it’s a less surprising "not defined" default.
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.

None yet

1 participant