diff --git a/app/scripts/comp/util/date-format.js b/app/scripts/comp/util/date-format.js index f9233c91..8f257fa1 100644 --- a/app/scripts/comp/util/date-format.js +++ b/app/scripts/comp/util/date-format.js @@ -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) + : ''; } }; diff --git a/test/src/util/formatting/date-format.js b/test/src/util/formatting/date-format.js index 51ff9b20..5361e912 100644 --- a/test/src/util/formatting/date-format.js +++ b/test/src/util/formatting/date-format.js @@ -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', () => {