Skip to content

Commit 9a73f75

Browse files
justingrantryzokuken
authored andcommitted
Document PDT use cases (fixes #948)
1 parent c6df297 commit 9a73f75

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

docs/plaindatetime.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,25 @@ A `Temporal.PlainDateTime` can be converted to a `Temporal.ZonedDateTime` using
1414

1515
A `Temporal.PlainDateTime` can be converted into any of the types mentioned above using conversion methods like `toZonedDateTime` or `toPlainDate`.
1616

17-
"Calendar date" and "wall-clock time" refer to the concept of time as expressed in everyday usage.
18-
`Temporal.PlainDateTime` does not represent an exact point in time; that is what exact-time types like `Temporal.ZonedDateTime` and `Temporal.Instant` are for.
19-
20-
One example of when it may be appropriate to use `Temporal.PlainDateTime` and not `Temporal.ZonedDateTime` nor `Temporal.Instant` is when integrating with wearable devices.
21-
FitBit, for example, always records sleep data in the user's wall-clock time, wherever they are in the world.
22-
Storing the time zone is not needed, and the plain (not exact) time is needed, because otherwise they would be recorded as sleeping at strange hours when travelling.
17+
Because `Temporal.PlainDateTime` does not represent an exact point in time, most date/time use cases are better handled using exact time types like `Temporal.ZonedDateTime` and `Temporal.Instant`.
18+
But there are cases where `Temporal.PlainDateTime` is the correct type to use:
19+
20+
- Representing timezone-specific events where the time zone is not stored together with the date/time data.
21+
In this case, `Temporal.PlainDateTime` is an intermediate step before converting to/from `Temporal.ZonedDateTime` or `Temporal.Instant` using the separate time zone.
22+
Examples:
23+
- When the time zone is stored separately in a separate database column or a per-user setting.
24+
- Implicit time zones, e.g. stock exchange data that is always `America/New_York`
25+
- Interacting with poorly-designed legacy systems that record data in the server's non-UTC time zone.
26+
- Passing data to/from a component that is unaware of time zones, e.g. a UI date/time picker.
27+
- Modeling events that happen at the same local time in every time zone.
28+
For example, the British Commonwealth observes a [two minute silence](https://en.wikipedia.org/wiki/Two-minute_silence) every November 11th at 11:00AM in local time.
29+
- When time zone is irrelevant, e.g. a sleep tracking device that only cares about the local time you went to sleep and woke up, regardless of where in the world you are.
30+
- Parsing local time from ISO 8601 strings like `2020-04-09T16:08-08:00` that have a numeric offset without an IANA time zone like `America/Los_Angeles`.
31+
These strings can also be parsed by `Temporal.Absolute`, but to parse the local date and time then `Temporal.PlainDateTime.from` is required.
32+
- Performing arithmetic that deliberately ignores DST.
33+
Example: in a day-planner UI, the visual height of a meeting may be the same even if DST skips or repeats an hour.
34+
35+
To learn more about time zones and DST best practices, visit [Time Zones and Resolving Ambiguity](./ambiguity.md).
2336

2437
## Constructor
2538

0 commit comments

Comments
 (0)