Replace moment.js with smaller day.js
This commit is contained in:
parent
f3d7584a46
commit
2ca6ac03d7
|
@ -15,7 +15,10 @@ $(function () {
|
||||||
// END string.format
|
// END string.format
|
||||||
|
|
||||||
// START Time functions
|
// START Time functions
|
||||||
console.log("Moment.js locale set to " + moment.locale());
|
dayjs.extend(window.dayjs_plugin_localizedFormat)
|
||||||
|
dayjs.extend(window.dayjs_plugin_relativeTime)
|
||||||
|
|
||||||
|
console.log("Day.js locale set to " + dayjs.locale());
|
||||||
|
|
||||||
updateRelativeTime();
|
updateRelativeTime();
|
||||||
|
|
||||||
|
@ -107,9 +110,8 @@ $(function () {
|
||||||
function timestampToDate(timestamp, full) {
|
function timestampToDate(timestamp, full) {
|
||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
var ld = moment.localeData()
|
var fuzzydate = dayjs.unix(timestamp).fromNow()
|
||||||
var fuzzydate = moment.unix(timestamp).fromNow()
|
var fulldate = dayjs.unix(timestamp).format("LLL")
|
||||||
var fulldate = moment.unix(timestamp).format(ld.longDateFormat("LLL"))
|
|
||||||
return full ? fulldate : fuzzydate
|
return full ? fulldate : fuzzydate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,14 +141,14 @@ function showPopover(el) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var describeSeconds = function (seconds) {
|
var describeSeconds = function (seconds) {
|
||||||
return moment().seconds(-seconds).fromNow()
|
return dayjs().subtract(seconds, 'second').fromNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
var describeTimestamp = function (timestamp, skipSuffix) {
|
var describeTimestamp = function (timestamp, skipSuffix) {
|
||||||
if (skipSuffix === undefined)
|
if (skipSuffix === undefined)
|
||||||
skipSuffix = true
|
skipSuffix = true
|
||||||
|
|
||||||
return moment.unix(timestamp).fromNow(skipSuffix)
|
return dayjs.unix(timestamp).fromNow(skipSuffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
var time = result.timenow
|
var time = result.timenow
|
||||||
|
|
|
@ -187,15 +187,16 @@ $navActiveIndex = isset($navActiveIndex) ? (int) $navActiveIndex : 0;
|
||||||
<!-- JS-Cookie 2.2.0 -->
|
<!-- JS-Cookie 2.2.0 -->
|
||||||
{$tplutils::includeScript("{cdnjs}/js-cookie/2.2.0/js.cookie.min.js", "sha256-9Nt2r+tJnSd2A2CRUvnjgsD+ES1ExvjbjBNqidm9doI=")}
|
{$tplutils::includeScript("{cdnjs}/js-cookie/2.2.0/js.cookie.min.js", "sha256-9Nt2r+tJnSd2A2CRUvnjgsD+ES1ExvjbjBNqidm9doI=")}
|
||||||
|
|
||||||
<!-- TODO: as soon as day.js matures with more languages, replace this obese library with it -->
|
<!-- day.js 1.9.3 -->
|
||||||
<!-- Moment.js 2.22.2 -->
|
{$tplutils::includeScript("{cdnjs}/dayjs/1.9.3/dayjs.min.js", "sha256-ty2mPrBF/8jcJe1+JfGM5l2HsYs7zEbs+f6X0norebo=")}
|
||||||
{$tplutils::includeScript("{cdnjs}/moment.js/2.24.0/moment.min.js", "sha256-4iQZ6BVL4qNKlQ27TExEhBN1HFPvAvAMbFavKKosSWQ=")}
|
{$tplutils::includeScript("{cdnjs}/dayjs/1.9.3/plugin/localizedFormat.min.js", "sha256-kP2eKuLMKEa/YcMNj0kW8qRpNtjAE4rJrS8PPL3vxCc=")}
|
||||||
|
{$tplutils::includeScript("{cdnjs}/dayjs/1.9.3/plugin/relativeTime.min.js", "sha256-K66CFTJDYaJ07agFxxju12e79nVEG+OuRN+hl9ivxYI=")}
|
||||||
|
|
||||||
{var $momentjslang = __get("MOMENTJS_LANG", [], true)}
|
{var $dayjslang = __get("DAYJS_LANG", [], true) ?? __get("MOMENTJS_LANG", [], true)}
|
||||||
{if $momentjslang !== null && $momentjslang !== "en-us"}
|
{if $dayjslang !== null && $dayjslang !== "en"}
|
||||||
{$tplutils::includeScript("{cdnjs}/moment.js/2.24.0/locale/$momentjslang.js")}
|
{$tplutils::includeScript("{cdnjs}/dayjs/1.9.3/locale/$dayjslang.js")}
|
||||||
<script>
|
<script>
|
||||||
moment.locale({$momentjslang} || navigator.languages || navigator.language)
|
dayjs.locale({$dayjslang} || navigator.languages || navigator.language)
|
||||||
</script>
|
</script>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue