- Notifications
You must be signed in to change notification settings - Fork1.6k
tzdb.cpp: Fall back to numeric offset when the current code page cannot represent the time zone short ID#5558
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
StephanTLavavej commentedJun 3, 2025
Thanks! 😻 I adjusted the code slightly, then manually verified that it still correctly prints both minutes and whole hours (by brain-surgery nulling out the abbrev pointer in the debugger). |
StephanTLavavej commentedJun 11, 2025
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
029ce56 intomicrosoft:mainUh oh!
There was an error while loading.Please reload this page.
StephanTLavavej commentedJun 14, 2025
Thanks for figuring out how to fix this in a reasonable way! 😻 🗺️ 🕥 |
| } | ||
| _Info->_Err = __std_tzdb_error::_Success; | ||
| _Info->_Abbrev = _Fallback_abbrev.release(); |
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 for commenting after a merge, but does thisrelease() call means we are leaking memory?
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.
We aren't leaking memory. The returned__std_tzdb_sys_info* will be stored in aunique_ptr<__std_tzdb_sys_info, _Tzdb_deleter<__std_tzdb_sys_info>>, which will call__std_tzdb_delete_sys_info in its destructor, which will performdelete[] _Info->_Abbrev;
Uh oh!
There was an error while loading.Please reload this page.
This PR adds a fallback time zone abbreviation of the form
-05or+0530when the system's code page cannot represent the localized time zone short ID produced by ICU. Previously such time zone short ID would result inERROR_NO_UNICODE_TRANSLATIONexceptions.The numeric offset form (
-05or+0530) is chosen because it is similar to the time zone abbreviation intzdb, and distinguishable from ICU's output.The behavior depends on the current user locale and the current code page. ForICU 77.1, the following locales have time zone short ID with non-ASCII characters, and thus might be affected by this fallback:
am,ar,as,bg,blo,brx,ckb,cs,dz,fa,ff_Adlm,ga,gd,he,hi,ii,km,ks,ks_Deva,ku,mai,ml,mni,nqo,sa,sat,sd,sd_Deva,si,sk,vi,xnr. In addition, the following locales have non-ASCII character (U+2212 or U+2013) as the minus sign, and thus are also affected:et,eu,fa,fr,lij,lt,se,sv.No tests are added because the
enlocale is unaffected.Fixes#3158
Fixes#5482