Improve date formatting (#1693)
* Update main.js * Update base.jet.html * Update CHANGELOG.md * Update en-us.all.json * Update ja-jp.all.json * Update main.js
Cette révision appartient à :
Parent
1f5d07a85c
révision
901c933632
5 fichiers modifiés avec 34 ajouts et 4 suppressions
|
@ -40,6 +40,13 @@ function toggleLayer(elem) {
|
|||
}
|
||||
}
|
||||
|
||||
// String formatter
|
||||
// "{0}{2}, {1}".format("foo", 123, "bar") == "foobar, 123"
|
||||
String.prototype.format = function() {
|
||||
var args = arguments
|
||||
return this.replace(/\{(\w+)\}/g, function(m, k) { return args[k] })
|
||||
}
|
||||
|
||||
function parseAllDates() {
|
||||
// Date formatting
|
||||
var lang = document.getElementsByTagName("html")[0].getAttribute("lang")
|
||||
|
@ -58,6 +65,7 @@ function parseAllDates() {
|
|||
var e = list[i]
|
||||
e.innerText = new Date(e.title).toLocaleString(lang, ymdOpt)
|
||||
e.title = new Date(e.title).toLocaleString(lang)
|
||||
e.classList.remove("date-short")
|
||||
}
|
||||
|
||||
var list = document.getElementsByClassName("date-full")
|
||||
|
@ -65,12 +73,13 @@ function parseAllDates() {
|
|||
var e = list[i]
|
||||
var dateDifference = dateDiff(new Date(e.innerText), new Date())
|
||||
|
||||
if(e.className != undefined && e.className.includes("scrape-date"))
|
||||
e.title = ((dateDifference.d * 24) + dateDifference.h) + " hours " + dateDifference.m + " minutes ago"
|
||||
if(e.classList.contains("scrape-date"))
|
||||
e.title = hmFmt.format((dateDifference.d * 24) + dateDifference.h, dateDifference.m)
|
||||
else
|
||||
e.title = dateDifference.d + " days " + dateDifference.h + " hours ago"
|
||||
e.title = dhFmt.format(dateDifference.d, dateDifference.h)
|
||||
|
||||
e.innerText = new Date(e.innerText).toLocaleString(lang)
|
||||
e.classList.remove("date-full")
|
||||
}
|
||||
}
|
||||
function dateDiff( str1, str2 ) {
|
||||
|
|
|
@ -100,7 +100,9 @@
|
|||
websiteVersion = "{{ Config.Version }}",
|
||||
UserID = {{User.ID}},
|
||||
domain = "{{getDomainName()}}",
|
||||
darkTheme = "{{DarkTheme}}";
|
||||
darkTheme = "{{DarkTheme}}",
|
||||
hmFmt = "{{ T("hours_minutes_ago") }}",
|
||||
dhFmt = "{{ T("days_hours_ago") }}";
|
||||
</script>
|
||||
<script type="text/javascript" src="/js/query.js?v={{ Config.Version}}{{ Config.Build }}"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/js/main.js?v={{ Config.Version }}{{ Config.Build }}" async></script>
|
||||
|
|
|
@ -60,3 +60,6 @@
|
|||
* + generating_torrent
|
||||
## 2017/10/09
|
||||
* + no_api_token
|
||||
## 2017/10/28
|
||||
* + hours_minutes_ago
|
||||
* + days_hours_ago
|
||||
|
|
|
@ -2174,5 +2174,13 @@
|
|||
{
|
||||
"id": "search_from_specific_user",
|
||||
"translation": "Search from %s"
|
||||
},
|
||||
{
|
||||
"id": "hours_minutes_ago",
|
||||
"translation": "{0} hours {1} minutes ago"
|
||||
},
|
||||
{
|
||||
"id": "days_hours_ago",
|
||||
"translation": "{0} days {1} hours ago"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -2174,5 +2174,13 @@
|
|||
{
|
||||
"id": "search_from_specific_user",
|
||||
"translation": "%s のアップロードを検索"
|
||||
},
|
||||
{
|
||||
"id": "hours_minutes_ago",
|
||||
"translation": "{0} 時間 {1} 分前"
|
||||
},
|
||||
{
|
||||
"id": "days_hours_ago",
|
||||
"translation": "{0} 日 {1} 時間前"
|
||||
}
|
||||
]
|
||||
|
|
Référencer dans un nouveau ticket