Repository navigation
0.4.9: where the user is (locale::region, locale::time_zone) - #30
Merged
Merged
Conversation
The region of the user's locale, ISO 3166-1 alpha-2: the first of LC_ALL, LC_MESSAGES and LANG that names one, and on Windows the user's geographic location (GetUserDefaultGeoName) before them. The system's time zone as the system names it: an IANA name from TZ, else from the zoneinfo file /etc/localtime links to, else /etc/timezone; on Windows the key of the dynamic time zone. Both are read without the network or a started program; an image and a wasm module read what they can of the same. region_of and zone_of read a locale's name and a TZ value or zoneinfo path. mcpp chooses its download mirror's initial value by them (mcpp-community/mcpp design 2026-11-27 section 3.13).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A new module,
mcpplibs.os.locale, exported bymcpplibs.os.locale::region(): the region of the user's locale, ISO 3166-1 alpha-2 in capitals. The first ofLC_ALL,LC_MESSAGESandLANGthat names one; on Windows the user's geographic location (GetUserDefaultGeoName) before them.locale::time_zone(): the system's time zone as the system names it. An IANA name fromTZ, else from the zoneinfo file/etc/localtimelinks to, else/etc/timezone; on Windows the key of the dynamic time zone (China Standard Time).locale::region_of,locale::zone_of: a locale's name (POSIX and BCP 47 spellings) and a TZ value or zoneinfo path.Both are read without the network and without starting a program. Every target but Windows shares one implementation (
src/locale/system.cpp, selected bycfg(not(windows))); Windows reaches kernel32 at run time, asmachinedoes. An image and a wasm module read what they can of the same.The consumer is mcpp's download mirror: its initial value is chosen by the time zone and the region, then checked against reachability (mcpp-community/mcpp design 2026-11-27 section 3.13).
Verification:
tests/locale_test.cpp(the parsing of both readers, and this machine's answers against its environment and/etc/localtime); the full suite on Linux; a build forx86_64-windows-gnu.