I'm writing a server app with swift and deploying with podman (basically a drop-in replacement for docker).
I've noticed that, for timestamps to render correctly in html output, I need to set the container's timezone. Easy enough, and it works. Timestamps come out at the correct time by default.
However, I'm in the US and we do dates the stupid way, MM-DD-YYYY
, while the default in linux/swift/not sure where it's actually coming from is DD-MM-YYYY
, which is honestly far more logical, but my dumb redneck monkey brain is too used to our stupid way.
I've updated the container's locale's to en_US
by running update-locale LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
and setting export LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
and can confirm the values have updated in the system settings (cat /etc/defaults/locale
and locale
reflect these values properly), but when using DateFormatter
inside swift it insists on using the DD-MM-YYYY
formatting, unless I explicitly set the instance's .locale
to Locale(identifier: "en_US")
in which case it finally formats it as MM-DD-YYYY
. .current
and .autoupdatingCurrent
both remain at the default en_001
.
Am I setting the wrong system locale setting to get that to propagate? Or perhaps reading from the system isn't yet implemented? I couldn't find any notes to that effect, but glancing at the foundation code, I see a couple hardcoded values for en_001
, which might imply that it's currently completely hardcoded.... But I didn't thoroughly parse the code to understand what it's doing.