# Time, time zones and keyboards Three things a person notices on their first day: the clock is right, it shows their own time (summer time included), and their keyboard types what is printed on it, accents too. ## The time of day The kernel's `clock` call answers the time of day, seconds since 1970 in UTC, and where it comes from (`pinnacle_rt::clock_ms`): the board's real-time clock (QEMU's PL031, a PC's CMOS clock), until the network has set it, then the network. An RK3399 has no clock driven yet, so until the network sets it the time of day is not known (0), and the Clock and the status bar show the time since boot. The **`time` service** (`programs/src/bin/time.rs`) sets it. It starts with the display server, before the password screen (it needs none of the person's data), and once the network is up: 1. asks an NTP server with Network Time Security (NTS, RFC 8915, `pinnacle_net::nts`): first a key exchange over TLS 1.3 with `time.cloudflare.com`, or `host` / `host:port` (4460 if none) in `/settings/time-server` (`rt::net::nts_keys`), which gives two keys exported from the TLS connection and cookies, each good for one request; then SNTP (`pinnacle_net::ntp`, RFC 4330) to the NTP server the exchange names, each request carrying a random identifier, a cookie, and an authenticator sealed with AES-SIV. An answer counts only when it echoes the identifier and is sealed with the server's key: anything else on the path is refused and the true answer waited for (`time: refused an answer to … that is not authenticated`). A random cookie is also the request's transmit time; half the round trip, less the time the server held the request, is added. The key exchange's certificates are checked at no time in particular, like the https date's below, and the time believed only within their life. 2. Where no NTS server answers (a network that lets no TCP port 4460 or UDP port 123 through), it takes the `Date` an https server sends (`https://pinnacle-os.eu/`, or `/settings/time-https`). The device's clock cannot be used to check that server's certificates, since it is what is being set: the chain is checked against the TLS roots at no time in particular (`tls::x509::chain_window`), and the date believed only within the span every certificate of it is valid (`rt::net::date`). A server cannot move the clock outside its own certificates' life. Then it sets the kernel's clock (`clock` op 1, not for an installed app), which also sets the board's clock where it can, so the next start begins right before there is a network. Again every six hours; after a try that found nothing, a minute later, doubling to ten. Each setting is in the log: `time: set to 2026-07-15 10:00:00 UTC from time.cloudflare.com (NTS, authenticated); the clock was 3 s behind`. Plain NTP, which anyone on the path can answer, is not asked at all; Settings says the time was set from the network, authenticated. ## Time zones The zones are IANA's database as data (`zoneinfo/`, its README): TZif files for every zone of `zone.tab`, on the system disk as `/zoneinfo`, which every app may read, and updated with the system as the TLS roots are. `pinnacle_tz` reads a file: the transitions it lists, then the rule in its footer (`CET-1CEST,M3.5.0,M10.5.0/3`) for every later year, and the civil calendar beside it. The zone chosen is a name in `system:/locale/zone`, which Settings writes and every app may read (`pinnacle_rt::locale`); none is UTC. The Clock, the status bar and the updates service's "last looked" show local time, read again each minute, so a change shows without a restart. **Settings → Date and time** shows the time and date now, the zone with its abbreviation and offset (and whether it is summer time), and where the time of day comes from. **Change** lists the regions, then a region's zones with their country and offset now. ## Keyboard layouts A physical key arrives as its place (a Linux key code); the layout says what that place types (`pinnacle_layout::keyboard::Layout`): | Layout | In `system:/locale/keyboard` | Dead keys | |---|---|---| | English (US) | `us` (also when none is chosen) | none | | English (US, international) | `us-intl` | `'` `"` `` ` `` `^` `~`; AltGr reaches é, ç, ß, € and more | | Dutch | `nl` | `¨` `^` beside P, `´` `` ` `` beside +, `~` and AltGr `¸` beside / | A dead key types nothing at first; the next letter gets its accent (`'` `e` is é, `"` `e` is ë, `'` `c` is ç on US-International, `¸` `c` on Dutch). A space after it types the accent itself; a letter it has no accent for types both. Ctrl's shortcuts go by the letter the layout puts on the key. `pinnacle_ui::keyboard::Keyboard` does this for every app built on it, reading the layout again a moment after a key when it was last read two seconds before, so a change in **Settings → Keyboard** reaches running apps. ## Seeing it `cargo xtask time-demo`: an NTS server on the host (its key exchange over TLS with a certificate of its own root, which the demo's system trusts) gives a summer's day, and before each of its answers a forged one, a year back, sealed with another key; the forged one is refused, the clock is set from the true one, Amsterdam chosen (two hours ahead), the Clock shows it; then a note typed on US-International and on Dutch with their dead keys (`target/demo-time`). ## Limits - The time is only as good as the server's certificates: one whose key was stolen could give a wrong time within their life, as with any TLS. With no clock to check them by, an expired certificate's key could too: the time is believed only within that certificate's own life. - A key exchange with every setting (each six hours), its cookies used for that setting only; NTS-KE over IPv6 works, its NTP needs IPv4. - The zone is not found from the network or the device's position; the person chooses it. - The on-screen keyboard is US letters only: no accents from it yet (a long press for é is the usual way). - Apps on the ports (Cartopolis, Flitz) map keys in the winit port, still as US. - An RK3399's own real-time clock (the RK808's) has no driver.