|
| 1 | +package wasi:clocks@0.3.0; |
| 2 | + |
| 3 | +@unstable(feature = clocks-timezone) |
| 4 | +interface timezone { |
| 5 | + @unstable(feature = clocks-timezone) |
| 6 | + use wall-clock.{datetime}; |
| 7 | + |
| 8 | + /// Return information needed to display the given `datetime`. This includes |
| 9 | + /// the UTC offset, the time zone name, and a flag indicating whether |
| 10 | + /// daylight saving time is active. |
| 11 | + /// |
| 12 | + /// If the timezone cannot be determined for the given `datetime`, return a |
| 13 | + /// `timezone-display` for `UTC` with a `utc-offset` of 0 and no daylight |
| 14 | + /// saving time. |
| 15 | + @unstable(feature = clocks-timezone) |
| 16 | + display: func(when: datetime) -> timezone-display; |
| 17 | + |
| 18 | + /// The same as `display`, but only return the UTC offset. |
| 19 | + @unstable(feature = clocks-timezone) |
| 20 | + utc-offset: func(when: datetime) -> s32; |
| 21 | + |
| 22 | + /// Information useful for displaying the timezone of a specific `datetime`. |
| 23 | + /// |
| 24 | + /// This information may vary within a single `timezone` to reflect daylight |
| 25 | + /// saving time adjustments. |
| 26 | + @unstable(feature = clocks-timezone) |
| 27 | + record timezone-display { |
| 28 | + /// The number of seconds difference between UTC time and the local |
| 29 | + /// time of the timezone. |
| 30 | + /// |
| 31 | + /// The returned value will always be less than 86400 which is the |
| 32 | + /// number of seconds in a day (24*60*60). |
| 33 | + /// |
| 34 | + /// In implementations that do not expose an actual time zone, this |
| 35 | + /// should return 0. |
| 36 | + utc-offset: s32, |
| 37 | + |
| 38 | + /// The abbreviated name of the timezone to display to a user. The name |
| 39 | + /// `UTC` indicates Coordinated Universal Time. Otherwise, this should |
| 40 | + /// reference local standards for the name of the time zone. |
| 41 | + /// |
| 42 | + /// In implementations that do not expose an actual time zone, this |
| 43 | + /// should be the string `UTC`. |
| 44 | + /// |
| 45 | + /// In time zones that do not have an applicable name, a formatted |
| 46 | + /// representation of the UTC offset may be returned, such as `-04:00`. |
| 47 | + name: string, |
| 48 | + |
| 49 | + /// Whether daylight saving time is active. |
| 50 | + /// |
| 51 | + /// In implementations that do not expose an actual time zone, this |
| 52 | + /// should return false. |
| 53 | + in-daylight-saving-time: bool, |
| 54 | + } |
| 55 | +} |
0 commit comments