github / github/relative-time-element
Force format to absolute iso8601
- Ngôn ngữ chính
- JavaScript
- Star
- 4k
- Fork
- 192
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 5
Mô tả
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?
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng việc xem xét các tùy chọn định dạng thời gian tương đối và hành vi của Intl.DateTimeFormat được đề cập trong issue. Công việc được coi là hoàn tất khi người dùng có thể yêu cầu dấu thời gian tuyệt đối theo kiểu ISO 8601 thay vì văn bản tương đối, với đầu ra dài hơn đáng kể so với định dạng hiện tại 'Thu, Sep 26'.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript
- Lĩnh vực
- frontend
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100