Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize number #2406

Merged
merged 3 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/js/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class Actions {
day.manipulate(1, Unit.month);
}

day.date = +currentTarget.innerText;
day.date = +currentTarget.getAttribute('data-day');
Eonasdan marked this conversation as resolved.
Show resolved Hide resolved
let index = 0;
if (this._context._options.multipleDates) {
index = this._context.dates.pickedIndex(day, Unit.date);
Expand Down Expand Up @@ -152,7 +152,7 @@ export default class Actions {
}
break;
case ActionTypes.selectMinute:
lastPicked.minutes = +currentTarget.innerText;
lastPicked.minutes = +currentTarget.getAttribute('data-value');
Eonasdan marked this conversation as resolved.
Show resolved Hide resolved
this._context.dates._setValue(
lastPicked,
this._context.dates.lastPickedIndex
Expand Down
11 changes: 4 additions & 7 deletions src/js/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class DateTime extends Date {
* Returns two digit hours
*/
get secondsFormatted(): string {
return this.seconds < 10 ? `0${this.seconds}` : `${this.seconds}`;
return this.format({ second: "2-digit" });
}

/**
Expand All @@ -297,7 +297,7 @@ export class DateTime extends Date {
* Returns two digit hours
*/
get minutesFormatted(): string {
return this.minutes < 10 ? `0${this.minutes}` : `${this.minutes}`;
return this.format({ minute: "2-digit" });
}

/**
Expand All @@ -318,17 +318,14 @@ export class DateTime extends Date {
* Returns two digit hours
*/
get hoursFormatted(): string {
return this.hours < 10 ? `0${this.hours}` : `${this.hours}`;
return this.format({ hour: "2-digit" });
}

/**
* Returns two digit hours but in twelve hour mode e.g. 13 -> 1
*/
get twelveHoursFormatted(): string {
let hour = this.hours;
if (hour > 12) hour = hour - 12;
if (hour === 0) hour = 12;
return hour < 10 ? `0${hour}` : `${hour}`;
return this.format({ hour12: true, hour: "2-digit" });
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/js/display/calendar/date-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ export default class DateDisplay {
'data-value',
`${innerDate.year}-${innerDate.monthFormatted}-${innerDate.dateFormatted}`
);
containerClone.innerText = `${innerDate.date}`;
containerClone.setAttribute(
'data-day',
`${innerDate.date}`
);
containerClone.innerText = innerDate.format({ day: "numeric" });
innerDate.manipulate(1, Unit.date);
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/js/display/calendar/decade-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class DecadeDisplay {

switcher.setAttribute(
Namespace.css.decadesContainer,
`${this._startDecade.year}-${this._endDecade.year}`
`${this._startDecade.format({ year: 'numeric' })}-${this._endDecade.format({ year: 'numeric' })}`
);

this._context._validation.isValid(this._startDecade, Unit.year)
Expand All @@ -79,7 +79,7 @@ export default class DecadeDisplay {
containerClone.setAttribute('data-value', ``);
return;
} else {
containerClone.innerText = `${this._startDecade.year - 10}`;
containerClone.innerText = this._startDecade.clone.manipulate(-10, Unit.year).format({ year: 'numeric' });
containerClone.setAttribute(
'data-value',
`${this._startDecade.year}`
Expand Down Expand Up @@ -107,7 +107,7 @@ export default class DecadeDisplay {
'data-value',
`${this._startDecade.year}`
);
containerClone.innerText = `${this._startDecade.year}`;
containerClone.innerText = `${this._startDecade.format({ year: 'numeric' })}`;

this._startDecade.manipulate(10, Unit.year);
});
Expand Down
4 changes: 2 additions & 2 deletions src/js/display/calendar/year-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class YearDisplay {

switcher.setAttribute(
Namespace.css.yearsContainer,
`${this._startYear.year}-${this._endYear.year}`
`${this._startYear.format({ year: 'numeric' })}-${this._endYear.format({ year: 'numeric' })}`
);

this._context._validation.isValid(this._startYear, Unit.year)
Expand Down Expand Up @@ -87,7 +87,7 @@ export default class YearDisplay {
containerClone.classList.remove(...containerClone.classList);
containerClone.classList.add(...classes);
containerClone.setAttribute('data-value', `${innerDate.year}`);
containerClone.innerText = `${innerDate.year}`;
containerClone.innerText = innerDate.format({ year: "numeric" });

innerDate.manipulate(1, Unit.year);
});
Expand Down