Hmm. I've had a good look into musl's locale code now. On the plus
side, it's small and tidy. On the down side, it comes as a unit that
we'd need to take in one lump: replace library.js locale functions in
one swoop, from setlocale() to nl_langinfo(). Feeding the browser's
date formatting data into this would messy, because musl's really not
designed to access that data except through its config files. (We'd
have similar difficulty if we tried to replace our custom time
functions (localtime(), gmtime()) with musl ones.)
strftime() is fundamentally an outdated/bad API, so it's good that the
browser doesn't offer it and instead has a high-level API that allows
a proper implementation using UTR#35. On the other hand, it makes
getting the data into musl hard from that side too.
For the time being, how about this very underwhelming suggestion:
https://github.com/NWilson/emscripten/commit/9ebe0270bcb9e6b61ce2a9e35e65a82edd818a16
For our product here, I've implemented some NSDate-like functions in a
JS library that give us tidy high-level access to the
Intl.DateTimeFormat data. I'm sorry, I'm not being very good at
sending code upstream, we're sitting on about 20 JS library files here
proving a C interface to Websockets, Flash applets, window.navigator,
WebCrypto, DOM storage, and more; it might be useful to someone but we
always have too much to do here!
I would like to make an effort at getting the musl locale and date
functions into emscripten, I just don't know when I'll get round to
it.
Nick