Files
iptvnator/libs/ui/pipes/src/lib/date-format.util.spec.ts
4gray c97673b928 refactor: refactor date handling across components to use date-fns and Intl.DateTimeFormat
- Replaced moment.js usage with Intl.DateTimeFormat for date formatting in various components.
- Introduced utility functions `normalizeDateLocale` and `formatWithIntl` for locale normalization and date formatting.
- Updated PlaylistSwitcher, RecentPlaylists, ContentCard, EPG components, and MultiEpgContainer to utilize the new date formatting approach.
- Removed moment-date pipe and related tests, simplifying date handling logic.
- Ensured all date displays respect the current locale settings.

Entire-Checkpoint: 271bd0162027
2026-04-11 10:41:33 +02:00

25 lines
858 B
TypeScript

import { formatWithIntl, normalizeDateLocale } from './date-format.util';
describe('date-format.util', () => {
it('normalizes app locale aliases to Angular/Intl locale ids', () => {
expect(normalizeDateLocale('ary')).toBe('ar-MA');
expect(normalizeDateLocale('by')).toBe('be');
expect(normalizeDateLocale('zhtw')).toBe('zh-Hant');
expect(normalizeDateLocale('de')).toBe('de');
expect(normalizeDateLocale()).toBe('en');
});
it('formats dates with cached Intl formatters', () => {
expect(
formatWithIntl('2026-04-05T12:30:00.000Z', {
locale: 'de',
timeZone: 'UTC',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
})
).toContain('12:30');
});
});