@date-io/dayjs
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -38,2 +38,3 @@ import defaultDayjs from "dayjs"; | ||
addDays(date: Dayjs, count: number): defaultDayjs.Dayjs; | ||
addMonths(date: Dayjs, count: number): defaultDayjs.Dayjs; | ||
setMonth(date: Dayjs, count: number): defaultDayjs.Dayjs; | ||
@@ -65,3 +66,4 @@ setHours(date: Dayjs, count: number): defaultDayjs.Dayjs; | ||
getYearRange(start: Dayjs, end: Dayjs): defaultDayjs.Dayjs[]; | ||
isWithinRange(date: Dayjs, [start, end]: [Dayjs, Dayjs]): boolean; | ||
} | ||
export {}; |
import defaultDayjs from 'dayjs'; | ||
import customParseFormatPlugin from 'dayjs/plugin/customParseFormat'; | ||
import localizedFormatPlugin from 'dayjs/plugin/localizedFormat'; | ||
import isBetweenPlugin from 'dayjs/plugin/isBetween'; | ||
defaultDayjs.extend(customParseFormatPlugin); | ||
defaultDayjs.extend(localizedFormatPlugin); | ||
defaultDayjs.extend(isBetweenPlugin); | ||
var withLocale = function (dayjs, locale) { | ||
@@ -119,11 +121,12 @@ return !locale ? dayjs : function () { | ||
DayjsUtils.prototype.addDays = function (date, count) { | ||
return count < 0 | ||
? date.clone().subtract(Math.abs(count), "day") | ||
: date.clone().add(count, "day"); | ||
return count < 0 ? date.subtract(Math.abs(count), "day") : date.add(count, "day"); | ||
}; | ||
DayjsUtils.prototype.addMonths = function (date, count) { | ||
return count < 0 ? date.subtract(Math.abs(count), "month") : date.add(count, "month"); | ||
}; | ||
DayjsUtils.prototype.setMonth = function (date, count) { | ||
return date.clone().set("month", count); | ||
return date.set("month", count); | ||
}; | ||
DayjsUtils.prototype.setHours = function (date, count) { | ||
return date.clone().set("hour", count); | ||
return date.set("hour", count); | ||
}; | ||
@@ -241,2 +244,6 @@ DayjsUtils.prototype.getMinutes = function (date) { | ||
}; | ||
DayjsUtils.prototype.isWithinRange = function (date, _a) { | ||
var start = _a[0], end = _a[1]; | ||
return date.isBetween(start, end); | ||
}; | ||
return DayjsUtils; | ||
@@ -243,0 +250,0 @@ }()); |
@@ -8,5 +8,7 @@ 'use strict'; | ||
var localizedFormatPlugin = _interopDefault(require('dayjs/plugin/localizedFormat')); | ||
var isBetweenPlugin = _interopDefault(require('dayjs/plugin/isBetween')); | ||
defaultDayjs.extend(customParseFormatPlugin); | ||
defaultDayjs.extend(localizedFormatPlugin); | ||
defaultDayjs.extend(isBetweenPlugin); | ||
var withLocale = function (dayjs, locale) { | ||
@@ -124,11 +126,12 @@ return !locale ? dayjs : function () { | ||
DayjsUtils.prototype.addDays = function (date, count) { | ||
return count < 0 | ||
? date.clone().subtract(Math.abs(count), "day") | ||
: date.clone().add(count, "day"); | ||
return count < 0 ? date.subtract(Math.abs(count), "day") : date.add(count, "day"); | ||
}; | ||
DayjsUtils.prototype.addMonths = function (date, count) { | ||
return count < 0 ? date.subtract(Math.abs(count), "month") : date.add(count, "month"); | ||
}; | ||
DayjsUtils.prototype.setMonth = function (date, count) { | ||
return date.clone().set("month", count); | ||
return date.set("month", count); | ||
}; | ||
DayjsUtils.prototype.setHours = function (date, count) { | ||
return date.clone().set("hour", count); | ||
return date.set("hour", count); | ||
}; | ||
@@ -246,2 +249,6 @@ DayjsUtils.prototype.getMinutes = function (date) { | ||
}; | ||
DayjsUtils.prototype.isWithinRange = function (date, _a) { | ||
var start = _a[0], end = _a[1]; | ||
return date.isBetween(start, end); | ||
}; | ||
return DayjsUtils; | ||
@@ -248,0 +255,0 @@ }()); |
{ | ||
"name": "@date-io/dayjs", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Abstraction over common javascript date management libraries", | ||
@@ -12,7 +12,7 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@date-io/core": "^2.4.0" | ||
"@date-io/core": "^2.5.0" | ||
}, | ||
"devDependencies": { | ||
"dayjs": "^1.8.17", | ||
"rollup": "^1.27.7", | ||
"rollup": "^2.0.2", | ||
"typescript": "^3.7.2" | ||
@@ -45,3 +45,3 @@ }, | ||
"license": "MIT", | ||
"gitHead": "d1b13999d15fce1c7b06d20654f1867ec6a7e096" | ||
"gitHead": "c6fc999bc503c79a913c2fd51a4bbce4427694d5" | ||
} |
import defaultDayjs from "dayjs"; | ||
import customParseFormatPlugin from "dayjs/plugin/customParseFormat"; | ||
import localizedFormatPlugin from "dayjs/plugin/localizedFormat"; | ||
import isBetweenPlugin from "dayjs/plugin/isBetween"; | ||
import { IUtils, DateIOFormats } from "@date-io/core/IUtils"; | ||
@@ -8,2 +9,3 @@ | ||
defaultDayjs.extend(localizedFormatPlugin); | ||
defaultDayjs.extend(isBetweenPlugin); | ||
@@ -162,13 +164,15 @@ interface Opts { | ||
public addDays(date: Dayjs, count: number) { | ||
return count < 0 | ||
? date.clone().subtract(Math.abs(count), "day") | ||
: date.clone().add(count, "day"); | ||
return count < 0 ? date.subtract(Math.abs(count), "day") : date.add(count, "day"); | ||
} | ||
public addMonths(date: Dayjs, count: number) { | ||
return count < 0 ? date.subtract(Math.abs(count), "month") : date.add(count, "month"); | ||
} | ||
public setMonth(date: Dayjs, count: number) { | ||
return date.clone().set("month", count); | ||
return date.set("month", count); | ||
} | ||
public setHours(date: Dayjs, count: number) { | ||
return date.clone().set("hour", count); | ||
return date.set("hour", count); | ||
} | ||
@@ -321,2 +325,6 @@ | ||
} | ||
public isWithinRange(date: Dayjs, [start, end]: [Dayjs, Dayjs]) { | ||
return date.isBetween(start, end); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32309
841
Updated@date-io/core@^2.5.0