@date-io/dayjs
Advanced tools
Comparing version 1.3.6 to 1.3.7
import defaultDayjs from "dayjs"; | ||
import { IUtils } from "@date-io/core/IUtils"; | ||
interface Opts { | ||
/** Locale string, only for consistency and rerendering */ | ||
locale?: string; | ||
@@ -6,0 +5,0 @@ /** Make sure that your dayjs instance extends customParseFormat and advancedFormat */ |
@@ -69,2 +69,3 @@ import defaultDayjs from 'dayjs'; | ||
DayjsUtils.prototype.format = function (date, formatString) { | ||
date.locale(this.locale); | ||
return date.format(formatString); | ||
@@ -132,3 +133,3 @@ }; | ||
DayjsUtils.prototype.getMonthText = function (date) { | ||
return date.format("MMMM"); | ||
return this.format(date, "MMMM"); | ||
}; | ||
@@ -147,5 +148,3 @@ DayjsUtils.prototype.getYear = function (date) { | ||
return [0, 1, 2, 3, 4, 5, 6].map(function (dayOfWeek) { | ||
return _this.dayjs() | ||
.set("day", dayOfWeek) | ||
.format("dd"); | ||
return _this.format(_this.dayjs().set("day", dayOfWeek), "dd"); | ||
}); | ||
@@ -193,24 +192,24 @@ }; | ||
DayjsUtils.prototype.getCalendarHeaderText = function (date) { | ||
return date.format("MMMM YYYY"); | ||
return this.format(date, "MMMM YYYY"); | ||
}; | ||
DayjsUtils.prototype.getYearText = function (date) { | ||
return date.format("YYYY"); | ||
return this.format(date, "YYYY"); | ||
}; | ||
DayjsUtils.prototype.getDatePickerHeaderText = function (date) { | ||
return date.format("ddd, MMM D"); | ||
return this.format(date, "ddd, MMM D"); | ||
}; | ||
DayjsUtils.prototype.getDateTimePickerHeaderText = function (date) { | ||
return date.format("MMM D"); | ||
return this.format(date, "MMM D"); | ||
}; | ||
DayjsUtils.prototype.getDayText = function (date) { | ||
return date.format("D"); | ||
return this.format(date, "D"); | ||
}; | ||
DayjsUtils.prototype.getHourText = function (date, ampm) { | ||
return date.format(ampm ? "hh" : "HH"); | ||
return this.format(date, ampm ? "hh" : "HH"); | ||
}; | ||
DayjsUtils.prototype.getMinuteText = function (date) { | ||
return date.format("mm"); | ||
return this.format(date, "mm"); | ||
}; | ||
DayjsUtils.prototype.getSecondText = function (date) { | ||
return date.format("ss"); | ||
return this.format(date, "ss"); | ||
}; | ||
@@ -217,0 +216,0 @@ return DayjsUtils; |
@@ -73,2 +73,3 @@ 'use strict'; | ||
DayjsUtils.prototype.format = function (date, formatString) { | ||
date.locale(this.locale); | ||
return date.format(formatString); | ||
@@ -136,3 +137,3 @@ }; | ||
DayjsUtils.prototype.getMonthText = function (date) { | ||
return date.format("MMMM"); | ||
return this.format(date, "MMMM"); | ||
}; | ||
@@ -151,5 +152,3 @@ DayjsUtils.prototype.getYear = function (date) { | ||
return [0, 1, 2, 3, 4, 5, 6].map(function (dayOfWeek) { | ||
return _this.dayjs() | ||
.set("day", dayOfWeek) | ||
.format("dd"); | ||
return _this.format(_this.dayjs().set("day", dayOfWeek), "dd"); | ||
}); | ||
@@ -197,24 +196,24 @@ }; | ||
DayjsUtils.prototype.getCalendarHeaderText = function (date) { | ||
return date.format("MMMM YYYY"); | ||
return this.format(date, "MMMM YYYY"); | ||
}; | ||
DayjsUtils.prototype.getYearText = function (date) { | ||
return date.format("YYYY"); | ||
return this.format(date, "YYYY"); | ||
}; | ||
DayjsUtils.prototype.getDatePickerHeaderText = function (date) { | ||
return date.format("ddd, MMM D"); | ||
return this.format(date, "ddd, MMM D"); | ||
}; | ||
DayjsUtils.prototype.getDateTimePickerHeaderText = function (date) { | ||
return date.format("MMM D"); | ||
return this.format(date, "MMM D"); | ||
}; | ||
DayjsUtils.prototype.getDayText = function (date) { | ||
return date.format("D"); | ||
return this.format(date, "D"); | ||
}; | ||
DayjsUtils.prototype.getHourText = function (date, ampm) { | ||
return date.format(ampm ? "hh" : "HH"); | ||
return this.format(date, ampm ? "hh" : "HH"); | ||
}; | ||
DayjsUtils.prototype.getMinuteText = function (date) { | ||
return date.format("mm"); | ||
return this.format(date, "mm"); | ||
}; | ||
DayjsUtils.prototype.getSecondText = function (date) { | ||
return date.format("ss"); | ||
return this.format(date, "ss"); | ||
}; | ||
@@ -221,0 +220,0 @@ return DayjsUtils; |
{ | ||
"name": "@date-io/dayjs", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"description": "Abstraction over common javascript date management libraries", | ||
@@ -12,3 +12,3 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@date-io/core": "^1.3.6" | ||
"@date-io/core": "^1.3.7" | ||
}, | ||
@@ -45,3 +45,3 @@ "devDependencies": { | ||
"license": "MIT", | ||
"gitHead": "75f08408e702874235295cf283747ed5c02193f0" | ||
"gitHead": "aae2e56035ae7edf3eb7fe7c187ab9504f1418e5" | ||
} |
@@ -10,3 +10,2 @@ import defaultDayjs from "dayjs"; | ||
interface Opts { | ||
/** Locale string, only for consistency and rerendering */ | ||
locale?: string; | ||
@@ -110,2 +109,3 @@ /** Make sure that your dayjs instance extends customParseFormat and advancedFormat */ | ||
public format(date: Dayjs, formatString: string) { | ||
date.locale(this.locale); | ||
return date.format(formatString); | ||
@@ -193,3 +193,3 @@ } | ||
public getMonthText(date: Dayjs) { | ||
return date.format("MMMM"); | ||
return this.format(date, "MMMM"); | ||
} | ||
@@ -214,5 +214,3 @@ | ||
return [0, 1, 2, 3, 4, 5, 6].map(dayOfWeek => | ||
this.dayjs() | ||
.set("day", dayOfWeek) | ||
.format("dd") | ||
this.format(this.dayjs().set("day", dayOfWeek), "dd") | ||
); | ||
@@ -271,32 +269,32 @@ } | ||
public getCalendarHeaderText(date: Dayjs) { | ||
return date.format("MMMM YYYY"); | ||
return this.format(date, "MMMM YYYY"); | ||
} | ||
public getYearText(date: Dayjs) { | ||
return date.format("YYYY"); | ||
return this.format(date, "YYYY"); | ||
} | ||
public getDatePickerHeaderText(date: Dayjs) { | ||
return date.format("ddd, MMM D"); | ||
return this.format(date, "ddd, MMM D"); | ||
} | ||
public getDateTimePickerHeaderText(date: Dayjs) { | ||
return date.format("MMM D"); | ||
return this.format(date, "MMM D"); | ||
} | ||
public getDayText(date: Dayjs) { | ||
return date.format("D"); | ||
return this.format(date, "D"); | ||
} | ||
public getHourText(date: Dayjs, ampm: boolean) { | ||
return date.format(ampm ? "hh" : "HH"); | ||
return this.format(date, ampm ? "hh" : "HH"); | ||
} | ||
public getMinuteText(date: Dayjs) { | ||
return date.format("mm"); | ||
return this.format(date, "mm"); | ||
} | ||
public getSecondText(date: Dayjs) { | ||
return date.format("ss"); | ||
return this.format(date, "ss"); | ||
} | ||
} |
27924
12
739
Updated@date-io/core@^1.3.7