feat(time): improve timezone handling by switching to jiff (#7222)

This commit is contained in:
David Knaack
2026-06-06 18:44:15 +02:00
committed by GitHub
parent 033f20b461
commit 3dd8c14144
6 changed files with 314 additions and 216 deletions
+23 -10
View File
@@ -4814,7 +4814,7 @@ format = 'via [$symbol$workspace]($style) '
## Time
The `time` module shows the current **local** time.
The `format` configuration value is used by the [`chrono`](https://crates.io/crates/chrono) crate to control how the time is displayed. Take a look [at the chrono strftime docs](https://docs.rs/chrono/0.4.7/chrono/format/strftime/index.html) to see what options are available.
The `format` configuration value is used by the [`jiff`](https://crates.io/crates/jiff) crate to control how the time is displayed. Take a look [at the jiff strftime docs](https://docs.rs/jiff/latest/jiff/fmt/strtime/index.html) to see what options are available.
> [!TIP]
> This module is disabled by default.
@@ -4822,15 +4822,15 @@ The `format` configuration value is used by the [`chrono`](https://crates.io/cra
### Options
| Option | Default | Description |
| ----------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `format` | `'at [$time]($style) '` | The format string for the module. |
| `use_12hr` | `false` | Enables 12 hour formatting |
| `time_format` | see below | The [chrono format string](https://docs.rs/chrono/0.4.7/chrono/format/strftime/index.html) used to format the time. |
| `style` | `'bold yellow'` | The style for the module time |
| `utc_time_offset` | `'local'` | Sets the UTC offset to use. Range from -24 < x < 24. Allows floats to accommodate 30/45 minute timezone offsets. |
| `disabled` | `true` | Disables the `time` module. |
| `time_range` | `'-'` | Sets the time range during which the module will be shown. Times must be specified in 24-hours format |
| Option | Default | Description |
| ----------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `format` | `'at [$time]($style) '` | The format string for the module. |
| `use_12hr` | `false` | Enables 12 hour formatting |
| `time_format` | see below | The [jiff format string](https://docs.rs/jiff/latest/jiff/fmt/strtime/index.html) used to format the time. |
| `style` | `'bold yellow'` | The style for the module time |
| `utc_time_offset` | `'local'` | Sets the UTC offset to use. Either an IANA time zone name or a range from -24 < x < 24. Allows floats to accommodate 30/45 minute timezone offsets. |
| `disabled` | `true` | Disables the `time` module. |
| `time_range` | `'-'` | Sets the time range during which the module will be shown. Times must be specified in 24-hours format |
If `use_12hr` is `true`, then `time_format` defaults to `'%r'`. Otherwise, it defaults to `'%T'`.
Manually setting `time_format` will override the `use_12hr` setting.
@@ -4846,6 +4846,8 @@ Manually setting `time_format` will override the `use_12hr` setting.
### Example
#### With UTC offset
```toml
# ~/.config/starship.toml
@@ -4857,6 +4859,17 @@ utc_time_offset = '-5'
time_range = '10:00:00-14:00:00'
```
#### With Timezone name
```toml
# ~/.config/starship.toml
[time]
disabled = false
time_format = '%T'
utc_time_offset = 'Europe/Berlin'
```
## Typst
The `typst` module shows the current installed version of Typst used in a project.