<relative-time> in Safari 14 displays "1 hours ago"
marcoroth opened this issue · comments
Hey there, thanks for this awesome project!
About two weeks ago I noticed this all over GitHub where relative time is displayed:
I've dug a little bit into it and I was able to reproduce it with current main
(on 4414cba).
Since the <relative-time>
element depends on Intl.RelativeTimeFormat
I had a look where it could originate from.
It works as expected if you pass no option.
new window.Intl.RelativeTimeFormat().format(-1, "hour")
=> "1 hour ago"
But as soon as you pass a parameter to it seems to mess it up:
new window.Intl.RelativeTimeFormat("en").format(-1, "hour")
=> "1 hours ago"
It looks like it just appears on Safari 14. I'm currently running Version 14.0.2 (14610.3.7.1.10)
and it happens for other locales too. But the issue doesn't appear on GitHub when browsing with Safari 13 (Version 13.1.3 (15609.4.1)
) .
Looks like Safari 14 is the first version to support Intl.RelativeTimeFormat
- but probably not as intended/expected.
Looking at the codebase it seems that on Safari 13 it falls back to formatEnRelativeTime()
here: https://github.com/github/time-elements/blob/4414cbacdb1e0cf95b7e99960897bb0c55736323/src/relative-time.ts#L190-L194
Is there a way we can address/fix this in this library or does this bug belong somewhere else?
Thank you!
Ha! Interesting, I thought it has to be the Safari version.
But I just updated my Safari to 14.0.3. But it looks like it's still broken with this version of WebKit: Version 14.0.3 (14610.4.3.1.7)
.
But there is probably not much you can do about it from your side. Unless I can upgrade my WebKit version manually? 😅
But there is probably not much you can do about it from your side.
Yeah, unfortunately. Hopefully you can update safari soon and then this issue should be resolved.
Alright, thanks for the investigation! 🙌🏼