— Replace moment.js with Date().toLocaleDateString(…)

This commit is contained in:
Luc Didry
2023-12-29 07:50:37 +01:00
parent a76b240ed8
commit 03dbeecac0
6 changed files with 15 additions and 7 deletions
+1
View File
@@ -5,6 +5,7 @@ Revision history for Lutim
- 💥 BREAKING CHANGE: no more twitter cards
- 🎨 — Use template literals in js
- 🐛 — Gallery, zip and random URLs are now updated when closing image dialog box
— Replace moment.js with Date().toLocaleDateString(…)
0.15.0 2023-12-19
- ✨ — Add --nuke option to image command
File diff suppressed because one or more lines are too long
@@ -86,7 +86,6 @@
%= javascript '/partial/lutim.js'
% }
% if (current_route 'myfiles') {
%= javascript '/js/moment-with-locales.min.js'
%= javascript '/partial/myfiles.js'
% }
</body>
@@ -219,3 +219,14 @@ function goodToast(msg) {
positionLeft: false
}).showToast();
}
function formatDate(unixTimestamp) {
return new Date(unixTimestamp * 1000).toLocaleString(window.navigator.language, {
year: 'numeric',
month: 'long',
day: 'numeric',
weekday: 'long',
hour: '2-digit',
minute: '2-digit',
})
}
@@ -117,7 +117,7 @@ function modifyDelay() {
},
success: function(data) {
updateItem(short, parseInt(limit), del_at_view);
var newLimit = (parseInt(limit, 10) === 0) ? '<%= l('No limit') %>' : moment.unix(limit * 86400 + created_at).locale(window.navigator.language).format('LLLL');
var newLimit = (parseInt(limit, 10) === 0) ? '<%= l('No limit') %>' : formatDate(limit * 86400 + created_at);
$(`#limit-${short}`).html(newLimit);
$(`#del_at_view-${short}`).html(delView(del_at_view));
$(`#edit-${short}`).data('moddelay', limit);
@@ -159,8 +159,8 @@ function populateFilesTable() {
var real_short = element.real_short;
var vlink = link(`${element.short}.${element.ext}`, '');
var dlink = link(real_short, 'dl', element.token, false, true);
var limit = (element.limit === 0) ? '<%= l('No limit') %>' : moment.unix(element.limit * 86400 + element.created_at).locale(window.navigator.language).format('LLLL');
var created_at = moment.unix(element.created_at).locale(window.navigator.language).format('LLLL');
var limit = (element.limit === 0) ? '<%= l('No limit') %>' : formatDate(element.limit * 86400 + element.created_at);
var created_at = formatDate(element.created_at);
var name = element.filename.replace(/</g, '&lt;').replace(/>/g, '&gt;');
var tr = `<tr id="alert-${real_short}">',
@@ -90,7 +90,6 @@
%= javascript '/partial/korrigan.js'
% }
% if (current_route 'myfiles') {
%= javascript '/js/moment-with-locales.min.js'
%= javascript '/partial/myfiles.js'
% }
</body>