mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
feat: show am/pm on date
we are cheating by using Date.toLocaleString(), that is fixed to "en" locale, for the time portion of the date
This commit is contained in:
parent
395361d5fc
commit
4fa3a54729
@ -821,6 +821,15 @@ page.prepareUploadConfig = () => {
|
||||
help: 'This will be used in our homepage, dashboard, and album public pages.',
|
||||
valueHandler () {} // Do nothing
|
||||
},
|
||||
ampmTime: {
|
||||
label: 'Show AM/PM on date',
|
||||
select: [
|
||||
{ value: 'default', text: 'No' },
|
||||
{ value: '1', text: 'Yes' }
|
||||
],
|
||||
help: 'This will be used in our homepage and dashboard.',
|
||||
valueHandler () {} // Do nothing
|
||||
},
|
||||
fileLength: {
|
||||
display: fileIdentifierLength,
|
||||
label: 'File identifier length',
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// keys for localStorage
|
||||
lsKeys.siBytes = 'siBytes'
|
||||
lsKeys.ampmTime = 'ampmTime'
|
||||
|
||||
page.prepareShareX = () => {
|
||||
const sharexElement = document.querySelector('#ShareX')
|
||||
@ -46,17 +47,19 @@ page.prepareShareX = () => {
|
||||
}
|
||||
|
||||
page.getPrettyDate = date => {
|
||||
// Not using .toLocaleString() for date display to maintain a global standard,
|
||||
// but its AM/PM logic is perfect for our use case as long as it's fixed to "en" locale.
|
||||
return date.getFullYear() + '/' +
|
||||
(date.getMonth() < 9 ? '0' : '') + // month's index starts from zero
|
||||
(date.getMonth() + 1) + '/' +
|
||||
(date.getDate() < 10 ? '0' : '') +
|
||||
date.getDate() + ' ' +
|
||||
(date.getHours() < 10 ? '0' : '') +
|
||||
date.getHours() + ':' +
|
||||
(date.getMinutes() < 10 ? '0' : '') +
|
||||
date.getMinutes() + ':' +
|
||||
(date.getSeconds() < 10 ? '0' : '') +
|
||||
date.getSeconds()
|
||||
date.toLocaleString('en', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: localStorage[lsKeys.ampmTime] === '1'
|
||||
})
|
||||
}
|
||||
|
||||
page.getPrettyBytes = num => {
|
||||
|
Loading…
Reference in New Issue
Block a user