mirror of
https://github.com/immich-app/immich.git
synced 2025-09-29 15:31:13 -04:00
fix(web): handle buckets before year 1000 (#21832)
This commit is contained in:
parent
03af60e8eb
commit
f29230c8a6
@ -1,6 +1,6 @@
|
|||||||
import { locale } from '$lib/stores/preferences.store';
|
import { locale } from '$lib/stores/preferences.store';
|
||||||
import { parseUtcDate } from '$lib/utils/date-time';
|
import { parseUtcDate } from '$lib/utils/date-time';
|
||||||
import { formatGroupTitle } from '$lib/utils/timeline-util';
|
import { formatGroupTitle, toISOYearMonthUTC } from '$lib/utils/timeline-util';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
|
||||||
describe('formatGroupTitle', () => {
|
describe('formatGroupTitle', () => {
|
||||||
@ -77,3 +77,13 @@ describe('formatGroupTitle', () => {
|
|||||||
expect(formatGroupTitle(date)).toBe('Invalid DateTime');
|
expect(formatGroupTitle(date)).toBe('Invalid DateTime');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('toISOYearMonthUTC', () => {
|
||||||
|
it('should prefix year with 0s', () => {
|
||||||
|
expect(toISOYearMonthUTC({ year: 28, month: 1 })).toBe('0028-01-01T00:00:00.000Z');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should prefix month with 0s', () => {
|
||||||
|
expect(toISOYearMonthUTC({ year: 2025, month: 1 })).toBe('2025-01-01T00:00:00.000Z');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -94,8 +94,11 @@ export const fromTimelinePlainYearMonth = (timelineYearMonth: TimelineYearMonth)
|
|||||||
{ zone: 'local', locale: get(locale) },
|
{ zone: 'local', locale: get(locale) },
|
||||||
) as DateTime<true>;
|
) as DateTime<true>;
|
||||||
|
|
||||||
export const toISOYearMonthUTC = ({ year, month }: TimelineYearMonth): string =>
|
export const toISOYearMonthUTC = ({ year, month }: TimelineYearMonth): string => {
|
||||||
`${year}-${month.toString().padStart(2, '0')}-01T00:00:00.000Z`;
|
const yearFull = `${year}`.padStart(4, '0');
|
||||||
|
const monthFull = `${month}`.padStart(2, '0');
|
||||||
|
return `${yearFull}-${monthFull}-01T00:00:00.000Z`;
|
||||||
|
};
|
||||||
|
|
||||||
export function formatMonthGroupTitle(_date: DateTime): string {
|
export function formatMonthGroupTitle(_date: DateTime): string {
|
||||||
if (!_date.isValid) {
|
if (!_date.isValid) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user