mirror of https://github.com/keeweb/keeweb
revert
parent
85a67b533a
commit
22754f32ec
|
@ -1,4 +1,5 @@
|
|||
import { SettingsManager } from 'comp/settings/settings-manager';
|
||||
import { StringFormat } from 'util/formatting/string-format';
|
||||
|
||||
const DateFormat = {
|
||||
getMonthsForLocale() {
|
||||
|
@ -61,7 +62,19 @@ const DateFormat = {
|
|||
if (typeof dt === 'number') {
|
||||
dt = new Date(dt);
|
||||
}
|
||||
return dt ? dt.toISOString().replaceAll(':', '-').slice(0, 19) : '';
|
||||
return dt
|
||||
? dt.getFullYear() +
|
||||
'-' +
|
||||
StringFormat.pad(dt.getMonth() + 1, 2) +
|
||||
'-' +
|
||||
StringFormat.pad(dt.getDate(), 2) +
|
||||
'T' +
|
||||
StringFormat.pad(dt.getHours(), 2) +
|
||||
'-' +
|
||||
StringFormat.pad(dt.getMinutes(), 2) +
|
||||
'-' +
|
||||
StringFormat.pad(dt.getSeconds(), 2)
|
||||
: '';
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@ import { expect } from 'chai';
|
|||
import { DateFormat } from 'comp/util/date-format';
|
||||
|
||||
describe('DateFormat', () => {
|
||||
const dt = new Date.UTC(2020, 0, 2, 3, 4, 5, 6);
|
||||
const dt = new Date(2020, 0, 2, 3, 4, 5, 6);
|
||||
|
||||
it('should format date', () => {
|
||||
expect(DateFormat.dStr(dt)).to.eql('Jan 2, 2020');
|
||||
});
|
||||
|
||||
it('should format date and time', () => {
|
||||
expect(DateFormat.dtStr(dt)).to.eql('Jan 2, 2020, 03:04:05 AM');
|
||||
expect(DateFormat.dtStr(dt)).to.eql('Jan 2, 2020, 03:04:05');
|
||||
});
|
||||
|
||||
it('should format date and time in sortable format', () => {
|
||||
|
|
Loading…
Reference in New Issue