github / github/relative-time-element

Title format is not configurable

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

Description

Hello, and thanks for this custom element!

I am starting to use `` in an app that supports multiple languages and users are in different countries. I started with the basics and just set the `datetime` attribute and inner text.

I noticed the automatic `title` always had short months. I tried to change it by setting `formatStyle="long"` and `month="long"` to no avail. Inspecting the source I found that titles use a fixed format:

https://github.com/github/relative-time-element/blob/7e40806f21684e46573e202527b9505e723d13e8/src/relative-time-element.ts#L116-L130

Thanks to the comment in the code above, I was able to temporarily solve for my use case by rendering the title from the server side, but that meant giving up showing the time in the timezone of the browser.

Would you consider re-using the style settings when formatting the title or provide a specific formatting rule for the title, independent from the inner text?

PS: Related, but less important, it would also be useful to add some text around the date, like `title="Updated at {formatted-date-here}"` (where the string "Updated at" is rendered in the correct locale on the server).

Thanks again!

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.