Main types¶
The whenever library provides four main date-time types, each
with its own purpose and behavior:
The available methods differ between these types based on whether they represent exact time or local time:
type |
represents exact time? |
represents local time? |
|---|---|---|
✅ |
❌ |
|
✅ |
✅ |
|
✅ |
✅ |
|
❌ |
✅ |
Exact time methods¶
The exact time classes (Instant, ZonedDateTime,
and OffsetDateTime) share several methods for working with
exact points in time:
|
|||
|
|||
|
deprecated, removed in 1.0 |
deprecated, removed in 1.0 |
|
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Timestamp conversion floors at the requested unit in both directions; see To and from timestamps.
Local time methods¶
The local time classes (PlainDateTime, ZonedDateTime,
and OffsetDateTime) share several methods for working with
local date and time values:
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Each type’s replacement carries its own resolution: disambiguation= on
ZonedDateTime, stale_offset_ok= on OffsetDateTime, and
nothing on PlainDateTime. Instant has no replace(),
because it has no local fields; see the FAQ.
Methods on all four types¶
Text in and out is shared by all four types; see ISO 8601 and
Pattern format. So is difference(), the exact time between two
values:
Other methods¶
Several other methods are unique to one or more classes:
OffsetDateTime and ZonedDateTime have no MIN and MAX:
their earliest and latest values depend on the offset or the time zone.
Note
from_utc() is the field constructor of Instant:
Instant(2020, 1, 1) does not exist because it would silently mean UTC.
See the FAQ.