|
| 1 | +# Clock Component |
| 2 | + |
| 3 | +- [Clock Component](#clock-component) |
| 4 | + - [Overview](#overview) |
| 5 | + - [Time Format Options](#time-format-options) |
| 6 | + - [Configuration](#configuration) |
| 7 | + - [Main Clock Configuration](#main-clock-configuration) |
| 8 | + - [Multiple Time Zones](#multiple-time-zones) |
| 9 | + - [IANA Timezone Names](#iana-timezone-names) |
| 10 | + - [Common Timezone Names](#common-timezone-names) |
| 11 | + - [Legacy Time Zone Offsets](#legacy-time-zone-offsets) |
| 12 | + |
| 13 | +## Overview |
| 14 | + |
| 15 | +The clock component has been enhanced to support multiple features: |
| 16 | + |
| 17 | +- 12-hour and 24-hour time formats |
| 18 | +- Multiple clocks for different time zones displayed in a row |
| 19 | +- Customizable formatting options |
| 20 | +- Locale support for regional time display |
| 21 | + |
| 22 | +## Time Format Options |
| 23 | + |
| 24 | +The clock format uses an extended version of the `strftime` function with the following format specifiers: |
| 25 | + |
| 26 | +| Format | Description | Example | |
| 27 | +| ------ | ----------------------------------- | --------------------- | |
| 28 | +| `H` | 24-hour format without leading zero | 9, 15 | |
| 29 | +| `h` | 24-hour format with leading zero | 09, 15 | |
| 30 | +| `K` | 12-hour format without leading zero | 9, 3 | |
| 31 | +| `k` | 12-hour format with leading zero | 09, 03 | |
| 32 | +| `i` | Minutes with leading zero | 05, 30 | |
| 33 | +| `M` | Minutes without leading zero | 5, 30 | |
| 34 | +| `s` | Seconds with leading zero | 08, 45 | |
| 35 | +| `S` | Seconds without leading zero | 8, 45 | |
| 36 | +| `p` | AM/PM uppercase | AM, PM | |
| 37 | +| `P` | AM/PM lowercase | am, pm | |
| 38 | +| `A` | Full weekday name | Monday, Tuesday | |
| 39 | +| `a` | Abbreviated weekday name | Mon, Tue | |
| 40 | +| `B` | Full month name | January, February | |
| 41 | +| `b` | Abbreviated month name | Jan, Feb | |
| 42 | +| `d` | Day of month with leading zero | 01, 28 | |
| 43 | +| `e` | Day of month without leading zero | 1, 28 | |
| 44 | +| `Y` | Full year | 2025 | |
| 45 | +| `y` | Two-digit year | 25 | |
| 46 | +| `z` | Full localized date and time | 5/31/2025, 9:30:45 PM | |
| 47 | + |
| 48 | +## Configuration |
| 49 | + |
| 50 | +### Main Clock Configuration |
| 51 | + |
| 52 | +In your `userconfig.js` file, you can configure the main clock: |
| 53 | + |
| 54 | +```javascript |
| 55 | +clock: { |
| 56 | + format: "k:i p", // 12-hour format with leading zero (09:30 PM) |
| 57 | + locale: "en-US", // Locale for date/time formatting |
| 58 | + icon_color: palette.maroon, |
| 59 | +}, |
| 60 | +``` |
| 61 | + |
| 62 | +### Multiple Time Zones |
| 63 | + |
| 64 | +To display additional clocks with different time zones: |
| 65 | + |
| 66 | +```javascript |
| 67 | +additionalClocks: [ |
| 68 | + // Method 1: Using IANA timezone names (preferred) |
| 69 | + { |
| 70 | + label: "NYC", // Label displayed next to the clock |
| 71 | + timezone: "America/New_York", // IANA timezone name (handles DST automatically) |
| 72 | + format: "k:i p", // Format (can be different from main clock) |
| 73 | + locale: "en-US", // Locale setting (optional) |
| 74 | + icon_color: palette.blue // Icon color (optional) |
| 75 | + }, |
| 76 | + |
| 77 | + // Method 2: Using timezone offset (legacy method) |
| 78 | + { |
| 79 | + label: "Paris", |
| 80 | + timezoneOffset: +1, // Hours offset from UTC (+1 for CET) |
| 81 | + format: "H:i", // 24-hour format without leading zero |
| 82 | + locale: "fr-FR", |
| 83 | + icon_color: palette.green |
| 84 | + } |
| 85 | +], |
| 86 | +``` |
| 87 | + |
| 88 | +## IANA Timezone Names |
| 89 | + |
| 90 | +Using IANA timezone names (e.g., "America/New_York") is preferred over timezone offsets as they automatically handle Daylight Saving Time changes. |
| 91 | + |
| 92 | +### Common Timezone Names |
| 93 | + |
| 94 | +| Region | IANA Timezone Name | |
| 95 | +| ----------------------- | ------------------------------ | |
| 96 | +| London, UK | Europe/London | |
| 97 | +| Paris, France | Europe/Paris | |
| 98 | +| Berlin, Germany | Europe/Berlin | |
| 99 | +| Kyiv, Ukraine | Europe/Kyiv | |
| 100 | +| Dubai, UAE | Asia/Dubai | |
| 101 | +| New Delhi, India | Asia/Kolkata | |
| 102 | +| Bangkok, Thailand | Asia/Bangkok | |
| 103 | +| Singapore | Asia/Singapore | |
| 104 | +| Hong Kong | Asia/Hong_Kong | |
| 105 | +| Tokyo, Japan | Asia/Tokyo | |
| 106 | +| Sydney, Australia | Australia/Sydney | |
| 107 | +| New York, USA | America/New_York | |
| 108 | +| Chicago, USA | America/Chicago | |
| 109 | +| Denver, USA | America/Denver | |
| 110 | +| Los Angeles, USA | America/Los_Angeles | |
| 111 | +| Honolulu, USA | Pacific/Honolulu | |
| 112 | +| São Paulo, Brazil | America/Sao_Paulo | |
| 113 | +| Buenos Aires, Argentina | America/Argentina/Buenos_Aires | |
| 114 | + |
| 115 | +### Legacy Time Zone Offsets |
| 116 | + |
| 117 | +If you prefer using timezone offsets, you can still use the following values: |
| 118 | + |
| 119 | +| City/Region | UTC Offset | |
| 120 | +| ------------------------- | ---------- | |
| 121 | +| London (GMT/UTC) | 0 | |
| 122 | +| Paris, Berlin, Rome (CET) | +1 | |
| 123 | +| Moscow | +3 | |
| 124 | +| Dubai | +4 | |
| 125 | +| New Delhi | +5.5 | |
| 126 | +| Bangkok | +7 | |
| 127 | +| Singapore, Hong Kong | +8 | |
| 128 | +| Tokyo | +9 | |
| 129 | +| Sydney | +10 | |
| 130 | +| New York (EST) | -5 | |
| 131 | +| Chicago (CST) | -6 | |
| 132 | +| Denver (MST) | -7 | |
| 133 | +| Los Angeles (PST) | -8 | |
| 134 | +| Honolulu | -10 | |
| 135 | + |
| 136 | +Note: When using timezone offsets, the values provided are for standard time and don't automatically adjust for Daylight Saving Time. |
0 commit comments