mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: datetime hourcycle formatting
This commit is contained in:
@@ -3,7 +3,8 @@ export const toLocaleDate = (datetime: string) => {
|
||||
const options: Intl.DateTimeFormatOptions = {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric'
|
||||
day: 'numeric',
|
||||
hourCycle: 'h23'
|
||||
};
|
||||
|
||||
return date.toLocaleDateString('en', options);
|
||||
@@ -17,7 +18,7 @@ export const toLocaleDateTime = (datetime: string | number) => {
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: 'numeric',
|
||||
hour12: false
|
||||
hourCycle: 'h23'
|
||||
};
|
||||
|
||||
return date.toLocaleDateString('en', options);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user