mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
All: Add new date format YYMMDD (#4954)
This commit is contained in:
parent
ce80d7e883
commit
fa6981faa8
@ -109,6 +109,9 @@ packages/app-cli/tests/Synchronizer.tags.js.map
|
|||||||
packages/app-cli/tests/Synchronizer.tools.d.ts
|
packages/app-cli/tests/Synchronizer.tools.d.ts
|
||||||
packages/app-cli/tests/Synchronizer.tools.js
|
packages/app-cli/tests/Synchronizer.tools.js
|
||||||
packages/app-cli/tests/Synchronizer.tools.js.map
|
packages/app-cli/tests/Synchronizer.tools.js.map
|
||||||
|
packages/app-cli/tests/dateTimeFormats.d.ts
|
||||||
|
packages/app-cli/tests/dateTimeFormats.js
|
||||||
|
packages/app-cli/tests/dateTimeFormats.js.map
|
||||||
packages/app-cli/tests/fsDriver.d.ts
|
packages/app-cli/tests/fsDriver.d.ts
|
||||||
packages/app-cli/tests/fsDriver.js
|
packages/app-cli/tests/fsDriver.js
|
||||||
packages/app-cli/tests/fsDriver.js.map
|
packages/app-cli/tests/fsDriver.js.map
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -96,6 +96,9 @@ packages/app-cli/tests/Synchronizer.tags.js.map
|
|||||||
packages/app-cli/tests/Synchronizer.tools.d.ts
|
packages/app-cli/tests/Synchronizer.tools.d.ts
|
||||||
packages/app-cli/tests/Synchronizer.tools.js
|
packages/app-cli/tests/Synchronizer.tools.js
|
||||||
packages/app-cli/tests/Synchronizer.tools.js.map
|
packages/app-cli/tests/Synchronizer.tools.js.map
|
||||||
|
packages/app-cli/tests/dateTimeFormats.d.ts
|
||||||
|
packages/app-cli/tests/dateTimeFormats.js
|
||||||
|
packages/app-cli/tests/dateTimeFormats.js.map
|
||||||
packages/app-cli/tests/fsDriver.d.ts
|
packages/app-cli/tests/fsDriver.d.ts
|
||||||
packages/app-cli/tests/fsDriver.js
|
packages/app-cli/tests/fsDriver.js
|
||||||
packages/app-cli/tests/fsDriver.js.map
|
packages/app-cli/tests/fsDriver.js.map
|
||||||
|
46
packages/app-cli/tests/dateTimeFormats.ts
Normal file
46
packages/app-cli/tests/dateTimeFormats.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import Setting from '@joplin/lib/models/Setting';
|
||||||
|
import time from '@joplin/lib/time';
|
||||||
|
|
||||||
|
describe('dateFormats', function() {
|
||||||
|
|
||||||
|
beforeEach(async (done) => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should format date according to DATE_FORMAT', (async () => {
|
||||||
|
|
||||||
|
const now = new Date('2017-01-30T12:00:00').getTime();
|
||||||
|
|
||||||
|
// DATE_FORMAT_1 = 'DD/MM/YYYY';
|
||||||
|
// DATE_FORMAT_2 = 'DD/MM/YY';
|
||||||
|
// DATE_FORMAT_3 = 'MM/DD/YYYY';
|
||||||
|
// DATE_FORMAT_4 = 'MM/DD/YY';
|
||||||
|
// DATE_FORMAT_5 = 'YYYY-MM-DD';
|
||||||
|
// DATE_FORMAT_6 = 'DD.MM.YYYY';
|
||||||
|
// DATE_FORMAT_7 = 'YYYY.MM.DD';
|
||||||
|
// DATE_FORMAT_8 = 'YYMMDD';
|
||||||
|
|
||||||
|
expect(time.formatMsToLocal(now, Setting.DATE_FORMAT_1)).toBe('30/01/2017');
|
||||||
|
expect(time.formatMsToLocal(now, Setting.DATE_FORMAT_2)).toBe('30/01/17');
|
||||||
|
expect(time.formatMsToLocal(now, Setting.DATE_FORMAT_3)).toBe('01/30/2017');
|
||||||
|
expect(time.formatMsToLocal(now, Setting.DATE_FORMAT_4)).toBe('01/30/17');
|
||||||
|
expect(time.formatMsToLocal(now, Setting.DATE_FORMAT_5)).toBe('2017-01-30');
|
||||||
|
expect(time.formatMsToLocal(now, Setting.DATE_FORMAT_6)).toBe('30.01.2017');
|
||||||
|
expect(time.formatMsToLocal(now, Setting.DATE_FORMAT_7)).toBe('2017.01.30');
|
||||||
|
expect(time.formatMsToLocal(now, Setting.DATE_FORMAT_8)).toBe('170130');
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should format time according to TIME_FORMAT', (async () => {
|
||||||
|
|
||||||
|
const now = new Date('2017-01-30T20:30:00').getTime();
|
||||||
|
|
||||||
|
// TIME_FORMAT_1 = 'HH:mm';
|
||||||
|
// TIME_FORMAT_2 = 'h:mm A';
|
||||||
|
|
||||||
|
expect(time.formatMsToLocal(now, Setting.TIME_FORMAT_1)).toBe('20:30');
|
||||||
|
expect(time.formatMsToLocal(now, Setting.TIME_FORMAT_2)).toBe('8:30 PM');
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
@ -131,6 +131,7 @@ class Setting extends BaseModel {
|
|||||||
public static DATE_FORMAT_5 = 'YYYY-MM-DD';
|
public static DATE_FORMAT_5 = 'YYYY-MM-DD';
|
||||||
public static DATE_FORMAT_6 = 'DD.MM.YYYY';
|
public static DATE_FORMAT_6 = 'DD.MM.YYYY';
|
||||||
public static DATE_FORMAT_7 = 'YYYY.MM.DD';
|
public static DATE_FORMAT_7 = 'YYYY.MM.DD';
|
||||||
|
public static DATE_FORMAT_8 = 'YYMMDD';
|
||||||
|
|
||||||
public static TIME_FORMAT_1 = 'HH:mm';
|
public static TIME_FORMAT_1 = 'HH:mm';
|
||||||
public static TIME_FORMAT_2 = 'h:mm A';
|
public static TIME_FORMAT_2 = 'h:mm A';
|
||||||
@ -562,6 +563,7 @@ class Setting extends BaseModel {
|
|||||||
options[Setting.DATE_FORMAT_5] = time.formatMsToLocal(now, Setting.DATE_FORMAT_5);
|
options[Setting.DATE_FORMAT_5] = time.formatMsToLocal(now, Setting.DATE_FORMAT_5);
|
||||||
options[Setting.DATE_FORMAT_6] = time.formatMsToLocal(now, Setting.DATE_FORMAT_6);
|
options[Setting.DATE_FORMAT_6] = time.formatMsToLocal(now, Setting.DATE_FORMAT_6);
|
||||||
options[Setting.DATE_FORMAT_7] = time.formatMsToLocal(now, Setting.DATE_FORMAT_7);
|
options[Setting.DATE_FORMAT_7] = time.formatMsToLocal(now, Setting.DATE_FORMAT_7);
|
||||||
|
options[Setting.DATE_FORMAT_8] = time.formatMsToLocal(now, Setting.DATE_FORMAT_8);
|
||||||
return options;
|
return options;
|
||||||
},
|
},
|
||||||
storage: SettingStorage.File,
|
storage: SettingStorage.File,
|
||||||
|
@ -378,7 +378,8 @@ The following commands are available in [command-line mode](#command-line-mode):
|
|||||||
DD/MM/YY (30/01/17), MM/DD/YYYY
|
DD/MM/YY (30/01/17), MM/DD/YYYY
|
||||||
(01/30/2017), MM/DD/YY (01/30/17),
|
(01/30/2017), MM/DD/YY (01/30/17),
|
||||||
YYYY-MM-DD (2017-01-30), DD.MM.YYYY
|
YYYY-MM-DD (2017-01-30), DD.MM.YYYY
|
||||||
(30.01.2017), YYYY.MM.DD (2017.01.30).
|
(30.01.2017), YYYY.MM.DD (2017.01.30),
|
||||||
|
YYMMDD (170130).
|
||||||
Default: "DD/MM/YYYY"
|
Default: "DD/MM/YYYY"
|
||||||
|
|
||||||
timeFormat Time format.
|
timeFormat Time format.
|
||||||
|
Loading…
Reference in New Issue
Block a user