Time Library icon

Time Library

Lightweight library for working with dates and time

Time Library icon

Time Library

Lightweight library for working with dates and time

This must-have library provides classes and functions to work with and format dates and time. Instead of relying on heavy JavaScript-based libraries that add to your build- and bundle-time, lib-time is just a thin wrapper around java.time classes that are already present in XP.

In addition to TypeScript-definitions for java.time (https://www.npmjs.com/package/@item-enonic-types/lib-time), this library also exports an easy-to-use formatDate({ date, pattern, locale }) function.

Releases

  1. 2.0.0

    • Add support Enonic for XP 8, and drop support for XP 7
    • Add `ChronoUnit`, the units of time from `NANOS` to `MILLENNIA`
    • Add `Duration`, an exact amount of time in hours, minutes and seconds
    • Add `Period`, an amount of years, months and days that follows the calendar
    • Allow date strings with a negative UTC offset for `formatDate()`
    • `formatDate()` now formats a `Date` in the system time zone when no `timezoneId` is given
    • Compatibility:

      • 8.0.0
  2. 1.6.1

    • Expose `FormatStyle` from index.ts
    • Compatibility:

      • 7.0.0
  3. 1.6.0

    • Add ability for `DateTimeFormatter` to use `FormatStyle` options to get localized formatter
    • Compatibility:

      • 7.0.0
  4. 1.5.0

    • Add support for `Year`
    • Compatibility:

      • 7.0.0
  5. 1.4.0

    • Add support for outputting localized display names for day-of-week and months
    • Compatibility:

      • 7.0.0
  6. 1.3.0

    • Add `getEpochSecond` and `toInstant` to `LocalDateTime` and `ZonedDateTime`
    • Compatibility:

      • 7.0.0
  7. 1.2.1

    • Support for `java.util.Locale.LanguageRange`
    • Compatibility:

      • 7.0.0
  8. 1.1.0

    • Added missing method types to LocalDate, LocalDateTime and ZonedDateTime
    • Added option to provide a timezoneId to formatDate()
    • Compatibility:

      • 7.0.0
  9. 1.0.0

    • General release
    • Compatibility:

      • 7.0.0