mirror of https://github.com/keeweb/keeweb.git
revert
This commit is contained in:
parent
85a67b533a
commit
22754f32ec
|
@ -1,4 +1,5 @@
|
||||||
import { SettingsManager } from 'comp/settings/settings-manager';
|
import { SettingsManager } from 'comp/settings/settings-manager';
|
||||||
|
import { StringFormat } from 'util/formatting/string-format';
|
||||||
|
|
||||||
const DateFormat = {
|
const DateFormat = {
|
||||||
getMonthsForLocale() {
|
getMonthsForLocale() {
|
||||||
|
@ -61,7 +62,19 @@ const DateFormat = {
|
||||||
if (typeof dt === 'number') {
|
if (typeof dt === 'number') {
|
||||||
dt = new Date(dt);
|
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';
|
import { DateFormat } from 'comp/util/date-format';
|
||||||
|
|
||||||
describe('DateFormat', () => {
|
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', () => {
|
it('should format date', () => {
|
||||||
expect(DateFormat.dStr(dt)).to.eql('Jan 2, 2020');
|
expect(DateFormat.dStr(dt)).to.eql('Jan 2, 2020');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should format date and time', () => {
|
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', () => {
|
it('should format date and time in sortable format', () => {
|
||||||
|
|
Loading…
Reference in New Issue