Skip to content

Releases: github/relative-time-element

v4.2.1

07 Feb 14:58
244af66
Compare
Choose a tag to compare

What's Changed

Full Changelog: v4.2.0...v4.2.1

v4.2.0

02 Feb 16:19
cce3194
Compare
Choose a tag to compare

What's Changed

Full Changelog: v4.1.6...v4.2.0

v4.1.6

02 Feb 15:57
9302a83
Compare
Choose a tag to compare
  • This release uses calendar months and years when balancing rounding of relative dates to a single unit. For example some displays that used to say "last year" will now more accurately say "2 years ago".

  • The year setter had a bug in which it was setting the day. Using .year = will now properly set the year.

What's Changed

New Contributors

Full Changelog: v4.1.5...v4.1.6

v4.1.5

16 Dec 20:55
220c8b9
Compare
Choose a tag to compare

What's Changed

  • allow opting out of months and weekdays on datetime format by @keithamus in #237

Full Changelog: v4.1.4...v4.1.5

v4.1.4

16 Dec 15:07
5d5e35a
Compare
Choose a tag to compare

What's Changed

  • avoid throwing errors for empty lang attributes by @keithamus in #235

Full Changelog: v4.1.3...v4.1.4

v4.1.3

16 Dec 09:02
fdba0e7
Compare
Choose a tag to compare

What's Changed

  • fix: fixes examples include to relative-time-element by @rafaeliga in #233
  • Increase rounding rules in roundToSingleUnit to 90% of the next largest unit by @keithamus in #234

New Contributors

Full Changelog: v4.1.2...v4.1.3

v4.1.2

14 Dec 08:47
60a8953
Compare
Choose a tag to compare

Full Changelog: v4.1.1...v4.1.2

v4.1.1

13 Dec 23:21
5810326
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v4.1.0...v4.1.1

v4.1.0

09 Dec 11:45
4ab3f28
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v4.0.0...v4.1.0

v4.0.0

29 Nov 15:00
424db49
Compare
Choose a tag to compare

What's Changed

The following features have been removed:

  • The package name has changed from @github/time-elements to @github/relative-time-element
  • The local-time element has been removed.
  • The time-ago element has been removed.
  • The time-until element has been removed.
  • getFormattedTitle is now only private.
  • getFormattedDate is now only private.
  • format no longer accepts a strftime compatible format. Instead, any value other than 'micro', 'elapsed' will revert to the string 'auto'
  • the Intl.DateTimeFormat constructor is not ponyfilled, and so in environments without this constructor, the
    element will fall back to provided text.
  • the Intl.RelativeTimeFormat constructor will not be ponyfilled, and so in environments without this constructor, the element will fall back to provided text.

Migrating package name change.

You should remove the old @github/time-elements package to avoid conflicts (npm rm @github/time-elements) and install the new version (npm i @github/[email protected]).

Migrating local-time to relative-time.

local-time was a configuration of relative-time. You can replicate the behaviour of local-time with the following relative-time tag:

<relative-time threshold="PT0S" day="numeric" month="short" year="numeric" datetime="$DATE">$DATE</relative-time>

Migrating time-ago to relative-time.

time-ago was a configuration of relative-time with a fixed tense. You can replicate the behaviour of time-ago with the following relative-time tag:

<relative-time tense="future" datetime="$DATE">$DATE</relative-time>

Migrating time-until to relative-time.

time-until was a configuration of relative-time with a fixed tense. You can replicate the behaviour of time-until with the following relative-time tag:

<relative-time tense="future" datetime="$DATE">$DATE</relative-time>

Migrating getFormattedTitle.

getFormattedTitle is now a private function. It is not possible to override this function, nor call it manually.

If you intend to subclass RelativeTimeElement, you can override the update() method which calls getFormattedTitle.

If you wanted to call getFormattedTitle() to retrieve the value, then this can be replaced with getAttribute('title').

Migrating getFormattedDate.

getFormattedDate is now a private function. It is not possible to override this function, nor call it manually.

If you intend to subclass RelativeTimeElement, you can override the update() method which calls getFormattedDate.

If you wanted to call getFormattedDate() to retrieve the value, then this can be replaced with shadowRoot.textContent.

Migrating strftime formatted format.

Using strftime style format strings has been removed. It is not possible to supply custom formatted dates in this way to relative-time.

strftime formatting was not locale aware, in that the position of segments was fixed by the format string - despite it being locale dependant.

Customisation of the date formatting is still possible using the day, month, year, weekday, hour, minute, second proprties. Please refer to the documentation on how to do this.

Migratting Intl.DateTimeFormat & Intl.RelativeTimeFormat ponyfills

This element no longer emulates the Intl.DateTimeFormat and Intl.RelativeTimeFormat classes if they do not exist. On browsers where these do not exist, the element will act as if it were inert, that is the title will not be set and the contents of the element will be whatever was rendered server side.

Intl.DateTimeFormat is supported natively by Chrome (24+), Edge (12+), Safari (10+), Firefox (29+), Opera (15+).
Intl.RelativeTimeFormat is supported natively by Chrome (71+), Edge (79+), Safari (14+), Firefox (65+), Opera (58+).

If you still wish to support older browsers, then please install polyfills for both of these constructors.

Full Changelog: v3.6.0...v4.0.