Skip to content

Commit

Permalink
HDS-3945 Remove Date type coercions, code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinLBradley committed Nov 15, 2024
1 parent 37c22cd commit 72bc5d0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/components/src/components/hds/time/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ export default class HdsTimeRange extends Component<HdsTimeRangeSignature> {
@service declare readonly hdsTime: TimeService;

get startDateIsoUtcString(): string | undefined {
return this.hdsTime.toIsoUtcString(this.args.startDate as Date);
const { startDate } = this.args;
if (startDate) {
return this.hdsTime.toIsoUtcString(startDate);
}
}

get endDateIsoUtcString(): string | undefined {
return this.hdsTime.toIsoUtcString(this.args.endDate as Date);
const { endDate } = this.args;
if (endDate) {
return this.hdsTime.toIsoUtcString(endDate);
}
}

get startDateDisplayFormat(): {
Expand All @@ -34,8 +40,7 @@ export default class HdsTimeRange extends Component<HdsTimeRangeSignature> {
minute?: Intl.DateTimeFormatOptions['minute'];
second?: Intl.DateTimeFormatOptions['second'];
} {
const { startDate } = this.args;
const { endDate } = this.args;
const { startDate, endDate } = this.args;

if (startDate?.getFullYear() !== endDate?.getFullYear()) {
return {
Expand Down

0 comments on commit 72bc5d0

Please sign in to comment.