Skip to content
Snippets Groups Projects
Commit b4474c88 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-2966 OZG-3098 format date for pdf filename

parent bff6e850
Branches
Tags
No related merge requests found
import { formatDate, registerLocaleData } from '@angular/common'; import { formatDate, registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de'; import localeDe from '@angular/common/locales/de';
import { formatForDatabase, formatFullDate, formatFullDateWithTimeAndDay, formatFullDateWithTimeWithoutSeconds, formatToPrettyDate, formatWithoutYear } from './date.util'; import { formatForDatabase, formatFullDate, formatFullDateWithoutSeperator, formatFullDateWithTimeAndDay, formatFullDateWithTimeWithoutSeconds, formatToPrettyDate, formatWithoutYear } from './date.util';
registerLocaleData(localeDe); registerLocaleData(localeDe);
...@@ -40,6 +40,12 @@ describe('Date Util', () => { ...@@ -40,6 +40,12 @@ describe('Date Util', () => {
expect(formattedDate).toEqual('01. Jan.'); expect(formattedDate).toEqual('01. Jan.');
}) })
it('should return full date without seperator', () => {
const formattedDate: string = formatFullDateWithoutSeperator(dateToFormat);
expect(formattedDate).toEqual('10100101');
})
describe('formatToPrettyDate()', () => { describe('formatToPrettyDate()', () => {
it('should format date without year', () => { it('should format date without year', () => {
......
...@@ -24,6 +24,10 @@ export function formatWithoutYear(date: Date): string { ...@@ -24,6 +24,10 @@ export function formatWithoutYear(date: Date): string {
return formatDate(date, 'dd. MMM', 'de'); return formatDate(date, 'dd. MMM', 'de');
} }
export function formatFullDateWithoutSeperator(date: Date): string {
return formatDate(date, 'yyyyMMdd', 'de');
}
export function formatToPrettyDate(date: Date): string { export function formatToPrettyDate(date: Date): string {
date = isValid(date) ? date : parseISO(date as unknown as string); date = isValid(date) ? date : parseISO(date as unknown as string);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment