github / github/relative-time-element
Enable passing `formatStyle` to Intl.DateTimeFormat
- Vorherrschende Sprache
- JavaScript
- Sterne
- 4k
- Forks
- 192
- Ø Merge
- 1 T. 10 Std.
- Gemergte PRs (30 T.)
- 5
Beschreibung
[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:
Beitragsleitfaden
Rechercherichtung
Beginne in src/relative-time-element.ts bei den referenzierten Zeilen um 173 und 188 und vergleiche die bestehende Konfiguration von Intl.RelativeTimeFormat mit Intl.DateTimeFormat. Lies die verlinkte MDN-Anleitung zu timeStyle und dateStyle und ermittle anschließend, wie die Komponente diese Optionen für das heutige Datum im Vergleich zu späteren Daten bereitstellen sollte. Als abgeschlossen gilt die Aufgabe, wenn Aufrufer die angeforderten Zeit- und Datumsstile über die Komponenten-API konfigurieren können.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- frontend, internationalization
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100