Skip to content

Commit cd3e325

Browse files
committed
Added string type to date and time pipe inputs.
1 parent 34944bf commit cd3e325

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

libs/extensions/angular/localization/src/date-time/abstract-timezone-compensating.pipe.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ export abstract class AbstractTimezoneCompensatingPipe implements PipeTransform
1313

1414
abstract transform(value: unknown, ...args: unknown[]): unknown;
1515

16-
protected format(time: number | Date, formatPattern: string): string {
16+
protected format(time: number | Date | string, formatPattern: string): string {
1717
if (!time) {
1818
return '';
1919
}
2020

21-
const date = typeof time === 'number' ? new Date(time) : time;
21+
const date = typeof time === 'number' || typeof time === 'string' ? new Date(time) : time;
2222

2323
const timeZone = this.config.timeZone;
2424
const options = this.getIntlOptions(formatPattern);

libs/extensions/angular/localization/src/date-time/date-only/date-only.pipe.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { DateFormats } from '../date-formats';
1111
standalone: true,
1212
})
1313
export class DateOnlyPipe extends AbstractTimezoneCompensatingPipe implements PipeTransform {
14-
transform(input: number | Date): string {
14+
transform(input: number | Date | string): string {
1515
return this.format(input, DateFormats.SHORT_DATE_FORMAT);
1616
}
1717
}

libs/extensions/angular/localization/src/date-time/time-only/time-only.pipe.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type TimeOnlyFormat = 'short' | 'medium';
1818
standalone: true,
1919
})
2020
export class TimeOnlyPipe extends AbstractTimezoneCompensatingPipe implements PipeTransform {
21-
transform(input: number | Date, format: TimeOnlyFormat = 'short'): string {
21+
transform(input: number | Date | string, format: TimeOnlyFormat = 'short'): string {
2222
return this.format(input, this.getFormat(format));
2323
}
2424

libs/extensions/angular/localization/src/date-time/time-or-date/time-or-date.pipe.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ import { DateFormats } from '../date-formats';
1818
})
1919
export class TimeOrDatePipe extends AbstractTimezoneCompensatingPipe implements PipeTransform {
2020
transform(
21-
time: number | Date,
21+
time: number | Date | string,
2222
showSeconds = false,
2323
formatMonth: 'month-as-digits' | 'month-as-letters' = 'month-as-digits'
2424
): string {
2525
if (!time) {
2626
return '';
2727
}
2828

29-
const date = typeof time === 'number' ? new Date(time) : time;
29+
const date = typeof time === 'number' || typeof time === 'string' ? new Date(time) : time;
3030

3131
const today = new Date();
3232
const sameDay =

libs/extensions/angular/localization/src/date-time/time-or-date/time-or-date.stories.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export class TimeOrDateExampleComponent {
2323
/**
2424
* An example timestamp to be formatted.
2525
*/
26-
@Input() myTimestamp!: number | Date;
26+
@Input() myTimestamp!: number | Date | string;
2727

2828
/**
2929
* The timestamp to be formatted.
3030
*/
31-
@Input() tomorrowTimestamp: number | Date = new Date(
31+
@Input() tomorrowTimestamp: number | Date | string = new Date(
3232
new Date().setDate(new Date().getDate() + 1)
3333
);
3434

libs/extensions/angular/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kirbydesign/extensions-angular",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"peerDependencies": {
55
"@angular/common": "^18.0.0 || ^19.0.0",
66
"@angular/compiler": "^18.0.0 || ^19.0.0",

0 commit comments

Comments
 (0)