datetimes
Version:
Extend class of Date
25 lines (20 loc) • 795 B
JavaScript
function DayExpression(dateRx, length, date, language) {
Expresion.call(this, dateRx, length, date, language);
this.oneDigit = oneDigit;
this.twoDigit = twoDigit;
this.threeDigit = threeDigit;
this.fourDigit = fourDigit;
this.otherDigit = null;
function oneDigit(input) {
return input.replace(this.dateRx, this.date.getDate().toString());
}
function twoDigit(input) {
return input.replace(this.dateRx, this.date.getDate().toString().padStart(2, '0'));
}
function threeDigit(input) {
return input.replace(this.dateRx, this.language.days[this.date.getDay()].substr(0,3));
}
function fourDigit(input) {
return input.replace(this.dateRx, this.language.days[this.date.getDay()]);
}
}