tempo 1.2.0
tempo: ^1.2.0 copied to clipboard
A complete time and date solution that replaces Dart's core DateTime with a rich set of date and time classes, advanced arithmetic features and full time zone support.
Changelog #
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.2.0 - 2026-02-12 #
Added #
operator+andoperator-operators on all datetime types that work on bothTimespanandPeriod- New, experimental
quantizecall. This can be use to round a datetime down (or up) to a specific precision. The specifics of how this works may change in the future.
Changed #
- The
Periodconstructor automatically normalizes values.
Fixed #
Periodnormalization now correctly handles negative values of year and month.Timespannormalization now correctly handles negative milli-, micro- and nanosecond values that exactly divide one second.
Deprecated #
Period.normalize()is now a no-op. Any calls can be safely removed.- All methods for adding and subtracting
TimespanandPeriod. Use the + and - operators instead.
1.1.0 - 2026-02-02 #
Added #
periodUntilmethods onOffsetDateTimeandZonedDateTime
Changed #
now()constructors forLocalTime,LocalDateandLocalDateTimeusedefaultZoneIdinstead ofDateTime's default.
Fixed #
- A bug when truncating values involving a very large number of nanoseconds to
microseconds:
- Converting a recent to
DateTimefrom times that were closer than 1 µs to midnight would incorrectly result in midnight the next day, instead of 1 µs to midnight on the same day. - Converting a large
Timespanto microseconds would sometimes round up when the nanosecond part was within 1 µs of the next second.
- Converting a recent to
1.0.1 - 2026-01-15 #
Fixed #
- Fixed a bug in
LocalDatewhen it was returned byLocalDateTime.date. They were not correctly pinned to midnight internally, which caused incorrect results in some cases.
1.0.0 - 2026-01-03 #
Added #
- New matchers for
HasInstantclasses that match the Unix timestamp:hasUnixSecondshasUnixMilliseecondshasUnixMicrosecondshasUnixNanosecondshasDateAndTime
- Added
format()methods that take aDateFormatfrom the intl package and return a string. - All date and datetime objects have an
inLeapYearproperty. replace()methods onOffsetDateTimeandZonedDateTimethat replace individual fields in the object.
Changed #
- Made some constructors
const:Timespan()Instant.fromUnix()ZoneOffset()LocalDate()LocalTime()LocalDateTime()OffsetDateTime.withOffset()
- All
minimumandmaximumdate time values areconstinstead offinal. - Using
clockpackage for allnow()constructors. - Improved failure output of
hasDateandhasTime - Constructors no longer throw exceptions when given an invalid date, but they
do guarantee a valid, albeit unspecified, result. (Other than
ZonedDateTime, which will still throw for invalid zone ids.)
Deprecated #
LocalDate.isLeapYear: UseinLeapYearinstead.
Removed #
- Breaking:
ZoneOffset.local()removed. Useoffseton aZonedDateTimeinstead. For example:ZonedDateTime.now().offset.
Fixed #
ZoneOffsetequals and hash code methods now correctly include thesecondscomponent.OffsetDateTime.now()now matches its documentation by returning times and offsets indefaultZoneId.
0.7.0 - 2025-08-02 #
Added #
- Missing conversion methods, and standardized the existing ones (see the library docs for a list of conversion method names)
- New ISO 8601
parse()constructors forInstantandZonedDateTime - Parses ISO date times with either a space or no separator instead of a 'T'
Changed #
- Breaking:
ZonedDateTime.defaultZoneIdmoved to a top-level getter/setter pair - Setting
defaultZoneIdto an invalid value now throws an exception - Breaking:
ZonedDateTime.toOffset()changed to a getter,asOffsetDateTime - Breaking:
toDateTime()no longer a part of theHasDateinterface - Breaking:
HasInstantnow usestoInstant()method instead ofasInstantgetter - Breaking:
OffsetDateTimenow defaults todefaultZoneIdinstead of UTC:- Removed
offsetarg from the unnamed constructor. UsewithOffsetconstructor instead - All other
offsetconstructor and conversion method args are now optional and default to the time zone indefaultZoneId - One exception: the
fromDateTimeconstructor continues to use the offset from theDateTimeit's given
- Removed
Removed #
- Breaking: All
asInstantgetters removed. UsetoInstant()instead.
Fixed #
- Breaking: DateTime extension method
toLocal()renamed totoLocalDateTime()so it doesn't shadow an existing method - Test matchers
hasDateandhasTimeno longer ignore unspecified fields, and instead check for expected defaults. For example,expect(LocalTime(4, 30), hasTime(4))used to pass. Now it fails, since the unspecified minute matcher defaults to 0.
0.6.0 - 2025-06-11 #
Added #
- Added
usandisogetters to Weekday for weekday numbers - Added extension methods on DateTime and Duration to convert to Tempo objects
Changed #
- Minimum Dart SDK is now 3.0.0
- Made zoneId optional for ZonedDateTime creation. This is seamless with one exception (see below)
- Breaking: Removed zoneId arg from ZonedDateTime(). Use ZonedDateTime.withZoneId() if you want to specify a time zone.
- ZonedDateTime now has a settable defaultZoneId field that will be used if none is provided.
- Improved documentation; assigned objects to categories and created category documentation pages.