github / github/relative-time-element

Force format to absolute iso8601

オープン
#293 コメント 2 件 リアクション 5 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
4k
フォーク
192
平均マージ
1日 10時間
マージ済み PR(30日)
5

説明

This code runs on github.com and displays timestamps in relative formatting...
but I really NEVER want to see timestamps in relative form.

I'd so much rather that 'last week' show up as '2024-09-26 19:05:24' or anything similar to iso8601.

Perhaps this just needs a new format string (for non-duration timestamps) of 'iso8601' ?

I can convince github pages to reveal an absolute timestamp with the following snippet pasted into the console.
```
document.querySelectorAll('relative-time[datetime]')
.forEach( item => {
item.setAttribute('format','datetime')
item.setAttribute('formatStyle','long')
item.setAttribute('precision','minute')
});
```
... but I get 'Thu, Sep 26' which is way too short.

I can use this snippet to update the title to show what I want but I still have to hover
```
document.querySelectorAll('relative-time[datetime]')
.forEach( item =>
item.setAttribute(
"title",
new Date(
Math.round(
Date.parse( item.getAttribute("datetime") )
/ 60000 ) * 60000
)
.toISOString()
.replace(/T/," ")
.replace(/[.].*/,"")
+" UTC"
)
)
```

perhaps I should be looking to convince Intl.DateTimeFormat with a Locale that emits iso8601 instead?

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、issue で言及されている相対時間フォーマットのオプションと Intl.DateTimeFormat の動作を確認します。ユーザーが相対テキストの代わりに ISO 8601 形式の絶対タイムスタンプを要求でき、出力が現在の 'Thu, Sep 26' 形式より大幅に長くなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
frontend
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。