github / github/relative-time-element

Enable passing `formatStyle` to Intl.DateTimeFormat

Open
#260 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4k
Forks
192
Avg merge
1d 10h
Merged PRs (30d)
5

Description

[Here](https://github.com/github/relative-time-element/blob/3a8f30f1a66edbe8d4e76c721ff1767c49b0ed27/src/relative-time-element.ts#L173) A style argument is being passed to the config of the Intl.RelativeTimeFormat constructor.

[But Here](https://github.com/github/relative-time-element/blob/3a8f30f1a66edbe8d4e76c721ff1767c49b0ed27/src/relative-time-element.ts#L188) There's no way to configure the `timeStyle` or `dateStyle` properties as described in the MDN docs below:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#using_timestyle_and_datestyle

We have a use case where for DateTime's fitting within the users "today" we only want to display the `timeStyle: 'short'`, but for DateTimes after today we only want to display the `dateStyle: 'short'` and with the current api I'm not sure how exactly to go about that :thinking:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.