|
9 | 9 |
|
10 | 10 | let date = $derived(providers.date); |
11 | 11 | let weather = $derived(providers.weather); |
| 12 | + let useCelsius = $derived(config.useCelsiusByDefault); |
12 | 13 |
|
13 | 14 | let fullDate = $derived(config.showFullDateByDefault); |
14 | 15 | const getDate = (date: Date) => { |
|
17 | 18 | return shortDay + " " + date.toLocaleDateString(); |
18 | 19 | }; |
19 | 20 |
|
20 | | - const timeOptions: Intl.DateTimeFormatOptions = { |
| 21 | + let timeOptions: Intl.DateTimeFormatOptions = $derived({ |
21 | 22 | hour: "numeric", |
22 | | - minute: "2-digit" |
23 | | - }; |
| 23 | + minute: "2-digit", |
| 24 | + ...(config.use24hClock === "auto" |
| 25 | + ? {} |
| 26 | + : config.use24hClock |
| 27 | + ? { hour12: false } |
| 28 | + : { hour12: true }), |
| 29 | + ...(config.showSeconds ? { second: "numeric" } : {}) |
| 30 | + }); |
24 | 31 | </script> |
25 | 32 |
|
26 | 33 | <div class="flex flex-row items-center h-full"> |
|
29 | 36 | <VolumeControl /> |
30 | 37 | {/if} |
31 | 38 | {#if config.showWeatherSection && weather} |
32 | | - <div |
33 | | - class="truncate flex items-center pr-2 {!isOnPrimaryMonitor() |
34 | | - ? 'pl-1' |
35 | | - : ''}" |
| 39 | + <button |
| 40 | + class="hover:text-zb-accent" |
| 41 | + onclick={() => (useCelsius = !useCelsius)} |
36 | 42 | > |
37 | | - <span class="text-2xl"> |
38 | | - {#if weather.status === "clear_day"} |
39 | | - <i class="nf nf-weather-day_sunny"></i> |
40 | | - {:else if weather.status === "clear_night"} |
41 | | - <i class="nf nf-weather-night_clear"></i> |
42 | | - {:else if weather.status === "cloudy_day"} |
43 | | - <i class="nf nf-weather-day_cloudy"></i> |
44 | | - {:else if weather.status === "cloudy_night"} |
45 | | - <i class="nf nf-weather-night_alt_cloudy"></i> |
46 | | - {:else if weather.status === "light_rain_day"} |
47 | | - <i class="nf nf-weather-day_sprinkle"></i> |
48 | | - {:else if weather.status === "light_rain_night"} |
49 | | - <i class="nf nf-weather-night_alt_sprinkle"></i> |
50 | | - {:else if weather.status === "heavy_rain_day"} |
51 | | - <i class="nf nf-weather-day_rain"></i> |
52 | | - {:else if weather.status === "heavy_rain_night"} |
53 | | - <i class="nf nf-weather-night_alt_rain"></i> |
54 | | - {:else if weather.status === "snow_day"} |
55 | | - <i class="nf nf-weather-day_snow"></i> |
56 | | - {:else if weather.status === "snow_night"} |
57 | | - <i class="nf nf-weather-night_alt_snow"></i> |
58 | | - {:else if weather.status === "thunder_day"} |
59 | | - <i class="nf nf-weather-day_lightning"></i> |
60 | | - {:else if weather.status === "thunder_night"} |
61 | | - <i class="nf nf-weather-night_alt_lightning"></i> |
| 43 | + <div |
| 44 | + class="truncate flex items-center pr-2 {!isOnPrimaryMonitor() |
| 45 | + ? 'pl-1' |
| 46 | + : ''}" |
| 47 | + > |
| 48 | + <span class="text-2xl"> |
| 49 | + {#if weather.status === "clear_day"} |
| 50 | + <i class="nf nf-weather-day_sunny"></i> |
| 51 | + {:else if weather.status === "clear_night"} |
| 52 | + <i class="nf nf-weather-night_clear"></i> |
| 53 | + {:else if weather.status === "cloudy_day"} |
| 54 | + <i class="nf nf-weather-day_cloudy"></i> |
| 55 | + {:else if weather.status === "cloudy_night"} |
| 56 | + <i class="nf nf-weather-night_alt_cloudy"></i> |
| 57 | + {:else if weather.status === "light_rain_day"} |
| 58 | + <i class="nf nf-weather-day_sprinkle"></i> |
| 59 | + {:else if weather.status === "light_rain_night"} |
| 60 | + <i class="nf nf-weather-night_alt_sprinkle"></i> |
| 61 | + {:else if weather.status === "heavy_rain_day"} |
| 62 | + <i class="nf nf-weather-day_rain"></i> |
| 63 | + {:else if weather.status === "heavy_rain_night"} |
| 64 | + <i class="nf nf-weather-night_alt_rain"></i> |
| 65 | + {:else if weather.status === "snow_day"} |
| 66 | + <i class="nf nf-weather-day_snow"></i> |
| 67 | + {:else if weather.status === "snow_night"} |
| 68 | + <i class="nf nf-weather-night_alt_snow"></i> |
| 69 | + {:else if weather.status === "thunder_day"} |
| 70 | + <i class="nf nf-weather-day_lightning"></i> |
| 71 | + {:else if weather.status === "thunder_night"} |
| 72 | + <i class="nf nf-weather-night_alt_lightning"></i> |
| 73 | + {/if} |
| 74 | + </span> |
| 75 | + {#if useCelsius} |
| 76 | + {Math.round(weather.celsiusTemp)}°C |
| 77 | + {:else} |
| 78 | + {Math.round(weather.fahrenheitTemp)}°F |
62 | 79 | {/if} |
63 | | - </span> |
64 | | - {Math.round(weather.celsiusTemp)}° |
65 | | - </div> |
| 80 | + </div> |
| 81 | + </button> |
66 | 82 | {/if} |
67 | 83 | {#if !isOnPrimaryMonitor() || !config.taskbarIntegration.enabled} |
68 | 84 | <PointFilled class="mr-2" /> |
|
71 | 87 | class="hover:text-zb-accent" |
72 | 88 | onclick={() => (fullDate = !fullDate)} |
73 | 89 | > |
74 | | - <p class="whitespace-nowrap"> |
75 | | - {date?.new.toLocaleTimeString(undefined, timeOptions)} |
| 90 | + <p class="whitespace-nowrap tabular-nums"> |
| 91 | + {date?.new.toLocaleTimeString(undefined, timeOptions).toUpperCase()} |
76 | 92 | {#if fullDate} |
77 | 93 | - |
78 | 94 | {date && getDate(date?.new)} |
|
0 commit comments