Merge pull request #153 from appwrite/fix-datetime-hour-cycle

fix: datetime hourcycle formatting
This commit is contained in:
Torsten Dittmann authored and GitHub committed 2022-11-17 14:03:50 +01:00
commit f89584bdd4
2 files changed
+25 -1

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ export const toLocaleDateTime = (datetime: string | number) => {
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
hour12: false
hourCycle: 'h23'
};
return date.toLocaleDateString('en', options);
+24
View File
@@ -0,0 +1,24 @@
import '@testing-library/jest-dom';
import { toLocaleDate, toLocaleDateTime } from '$lib/helpers/date';
describe('local date', () => {
[
['2022-11-15 08:26:28', 'Nov 15, 2022'],
['2022-11-15 00:26:28', 'Nov 15, 2022']
].forEach(([value, expected]) => {
it(value, () => {
expect(toLocaleDate(value)).toBe(expected);
});
});
});
describe('local date time', () => {
[
['2022-11-15 08:26:28', 'Nov 15, 2022, 08:26'],
['2022-11-15 00:26:28', 'Nov 15, 2022, 00:26']
].forEach(([value, expected]) => {
it(value, () => {
expect(toLocaleDateTime(value)).toBe(expected);
});
});
});