Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Mar 21, 2024

Without this change then timezone names will be the long form (Pacific
Standard Time) rather than the short form (PST), and since TZNAME_MAX
in musl is 6 (same in POSIX) the long names were getting truncated.

Fixes: #21582

@sbc100 sbc100 force-pushed the tzname_max branch 3 times, most recently from f627c7d to a98f6de Compare March 21, 2024 23:01
@sbc100 sbc100 requested review from dschuff and kripken March 21, 2024 23:02
@sbc100 sbc100 changed the title Assert if timezone name is truncated Use short timezone names in _tzset_js Mar 21, 2024
Without this change then timezone names will be the long form (Pacific
Standard Time) rather than the short form (PST), and since TZNAME_MAX
in musl is 6 (same in POSIX) the long names were getting truncated.

Fixes emscripten-core#21582
@sbc100 sbc100 enabled auto-merge (squash) March 22, 2024 00:35
@sbc100 sbc100 merged commit efb2ffc into emscripten-core:main Mar 22, 2024
@sbc100 sbc100 deleted the tzname_max branch March 22, 2024 01:40
@jrobichaux
Copy link

jrobichaux commented Mar 22, 2024

sorry to jump in here, but on the call to:

date.toLocaleTimeString(undefined, {timeZoneName:'short'}).split(' ')[2];

that works properly for me with English US settings (returns "EDT"), but if I change to English UK it returns "undefined" because it's a 24-hour clock (no AM/PM in the string).

@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 22, 2024

sorry to jump in here, but on the call to:

date.toLocaleTimeString(undefined, {timeZoneName:'short'}).split(' ')[2];

that works properly for me with English US settings (returns "EDT"), but if I change to English UK it returns "undefined" because it's a 24-hour clock (no AM/PM in the string).

What does date.toLocaleTimeString(undefined, {timeZoneName:'short'}) return in this case?

Should I pass en.us as the first argument here to force English US maybe?

sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 22, 2024
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 22, 2024
@jrobichaux
Copy link

With my regional settings on English UK the call to date.toLocaleTimeString(undefined, {timeZoneName:'short'}) returns e.g. "11:55:09 GMT-4" using Edge on Windows 10.

If I change the call to date.toLocaleTimeString('en-US', {timeZoneName:'short'}) it returns e.g. "11:59:21 AM EDT" which is what you're looking for, but I have no idea if en-US is available for all browsers in all languages.

@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 22, 2024

I opened #21596 to fix this issue and add more testing.

sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 22, 2024
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 22, 2024
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 22, 2024
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 22, 2024
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 22, 2024
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 22, 2024
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 25, 2024
sbc100 added a commit that referenced this pull request Mar 25, 2024
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.

put_time returning time zone as "Easter"

3 participants