Provides type classes for datetime values. Works both on JVM & ScalaJS.
Scala 2.13 support.
This major release aims to fix a specific design flaw, which is impossibility to construct Local
values from
zone-aware instants. Prior to 2.0, such option was an exclusive privilege of Zoned
.
In practice this introduced limitations in correctly abstracting over UTC/Zoned time representations.
Inability to grasp this aspect from the beginning leaded to creation of arcane localDateTimeAsZoned
instance.
This trick allowed to use LocalDateTime
in Zoned
context, which provided an ability to construct values polymorphically.
Such abuse created it's own issues, in particular - ability to create LocalDateTime
values in some Zoned
contexts,
where it didn't make any sense.
Version 2.0 resolves this issue by extracting time creation functionality in a separate Capture
typeclass.
Now it's possible to specify an exact polymorphic context you need:
TimePoint
for a generic instantTimePoint
+ Capture
for a generic instant that can be constructed in a instant-preserving way.Zoned
for a zone-aware value for full control over zoning (no locals here from now on)Local
specifically for local (or UTC) instant, without zone information and control over it.Now there's no Zoned
instance for LocalDateTime
.
For each place you use it there're two options:
Zoned
to TimePoint
+ Capture
.Zoned.of[T](...)
was removed. Use Capture[T](...)
Lawless
was renamed to TimePoint
.
hashCode
was added to moment wrapper classes,
which can lead to different behaviour in Map
s.Zoned.constructorConsistency
law is gone. Proper laws for Capture
are work in progress.