Skip to content

Commit

Permalink
fix(cdk): toLocalNativeDate correct work with years less 1900
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy committed Nov 12, 2024
1 parent 727ffa4 commit 0516d59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion projects/cdk/date-time/date-time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const MIN_MONTH = 0;

export const MAX_MONTH = 11;

export const MIN_YEAR = 100;
export const MIN_YEAR = 0;

export const MAX_YEAR = 9999;

Expand Down
7 changes: 6 additions & 1 deletion projects/cdk/date-time/day.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,12 @@ export class TuiDay extends TuiMonth {
* Returns native {@link Date} based on local time zone
*/
override toLocalNativeDate(): Date {
return new Date(this.year, this.month, this.day);
const date = new Date(this.year, this.month, this.day);

// needed for years less than 1900
date.setFullYear(Number(this.year ?? '0'));

return date;
}

/**
Expand Down

0 comments on commit 0516d59

Please sign in to comment.