Respect user preferences when formatting timestamp (#7994)

This is a follow up to #7945. The current behaviour reads the locale and
infers from that which type of time format should be used (12 hour/24
hour).
However, in macOS you can override this behaviour, e.g. you can use
en_US locale but still use the 24 hour clock format (Can be customized
under Settings > General > Date & Format > 24-hour time). You can even
customize the date format.

This PR uses the macOS specific `CFDateFormatter` API, which outputs
time format strings, that respect those settings.

Partially fixes #7956 (as its not implemented for linux)

Release Notes:

- Added localization support for all macOS specific date and time
configurations in chat
This commit is contained in:
Bennet Bo Fenner 2024-02-24 03:18:06 +01:00 committed by GitHub
parent 7599933f30
commit dc7e14f888
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 571 additions and 263 deletions

61
Cargo.lock generated
View file

@ -365,7 +365,7 @@ dependencies = [
"tiktoken-rs",
"ui",
"util",
"uuid 1.4.1",
"uuid",
"workspace",
]
@ -861,7 +861,7 @@ dependencies = [
"percent-encoding",
"pin-project-lite 0.2.13",
"tracing",
"uuid 1.4.1",
"uuid",
]
[[package]]
@ -1754,7 +1754,7 @@ dependencies = [
"tiny_http",
"url",
"util",
"uuid 1.4.1",
"uuid",
]
[[package]]
@ -1976,7 +1976,7 @@ dependencies = [
"tiny_http",
"url",
"util",
"uuid 1.4.1",
"uuid",
]
[[package]]
@ -2118,7 +2118,7 @@ dependencies = [
"tracing-subscriber",
"unindent",
"util",
"uuid 1.4.1",
"uuid",
"workspace",
]
@ -2165,6 +2165,7 @@ dependencies = [
"theme",
"theme_selector",
"time",
"time_format",
"tree-sitter-markdown",
"ui",
"util",
@ -2345,7 +2346,6 @@ checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
dependencies = [
"core-foundation-sys 0.8.6",
"libc",
"uuid 0.5.1",
]
[[package]]
@ -4185,7 +4185,7 @@ dependencies = [
"tiny-skia",
"usvg",
"util",
"uuid 1.4.1",
"uuid",
"waker-fn",
"wayland-backend",
"wayland-client",
@ -4710,7 +4710,7 @@ dependencies = [
"rand 0.7.3",
"serde",
"tempfile",
"uuid 1.4.1",
"uuid",
"winapi 0.3.9",
]
@ -7756,7 +7756,7 @@ dependencies = [
"rkyv_derive",
"seahash",
"tinyvec",
"uuid 1.4.1",
"uuid",
]
[[package]]
@ -8263,7 +8263,7 @@ dependencies = [
"time",
"tracing",
"url",
"uuid 1.4.1",
"uuid",
]
[[package]]
@ -8294,7 +8294,7 @@ dependencies = [
"rust_decimal",
"serde_json",
"time",
"uuid 1.4.1",
"uuid",
]
[[package]]
@ -8310,7 +8310,7 @@ dependencies = [
"serde_json",
"sqlx",
"time",
"uuid 1.4.1",
"uuid",
]
[[package]]
@ -8947,7 +8947,7 @@ dependencies = [
"smol",
"thread_local",
"util",
"uuid 1.4.1",
"uuid",
]
[[package]]
@ -9030,7 +9030,7 @@ dependencies = [
"tokio-stream",
"tracing",
"url",
"uuid 1.4.1",
"uuid",
"webpki-roots",
]
@ -9116,7 +9116,7 @@ dependencies = [
"thiserror",
"time",
"tracing",
"uuid 1.4.1",
"uuid",
"whoami",
]
@ -9161,7 +9161,7 @@ dependencies = [
"thiserror",
"time",
"tracing",
"uuid 1.4.1",
"uuid",
"whoami",
]
@ -9187,7 +9187,7 @@ dependencies = [
"time",
"tracing",
"url",
"uuid 1.4.1",
"uuid",
]
[[package]]
@ -9703,7 +9703,7 @@ dependencies = [
"story",
"toml 0.8.10",
"util",
"uuid 1.4.1",
"uuid",
]
[[package]]
@ -9728,7 +9728,7 @@ dependencies = [
"simplelog",
"strum",
"theme",
"uuid 1.4.1",
"uuid",
"vscode_theme",
]
@ -9844,6 +9844,19 @@ dependencies = [
"time-core",
]
[[package]]
name = "time_format"
version = "0.1.0"
dependencies = [
"anyhow",
"core-foundation",
"core-foundation-sys 0.8.6",
"lazy_static",
"sys-locale",
"time",
"util",
]
[[package]]
name = "tiny-skia"
version = "0.5.1"
@ -10986,12 +10999,6 @@ dependencies = [
"url",
]
[[package]]
name = "uuid"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcc7e3b898aa6f6c08e5295b6c89258d1331e9ac578cc992fb818759951bdc22"
[[package]]
name = "uuid"
version = "1.4.1"
@ -11944,7 +11951,7 @@ dependencies = [
"theme",
"ui",
"util",
"uuid 1.4.1",
"uuid",
]
[[package]]
@ -12224,7 +12231,7 @@ dependencies = [
"url",
"urlencoding",
"util",
"uuid 1.4.1",
"uuid",
"vim",
"welcome",
"workspace",