chronoshift
Advanced tools
Comparing version 0.10.1 to 0.10.2
@@ -232,2 +232,8 @@ "use strict"; | ||
}; | ||
Duration.prototype.ceil = function (date, timezone) { | ||
var floored = this.floor(date, timezone); | ||
if (floored.valueOf() === date.valueOf()) | ||
return date; | ||
return this.shift(floored, timezone, 1); | ||
}; | ||
Duration.prototype.shift = function (date, timezone, step) { | ||
@@ -234,0 +240,0 @@ if (step === void 0) { step = 1; } |
@@ -229,2 +229,8 @@ import { second, shifters } from '../floor-shift-ceil/floor-shift-ceil'; | ||
}; | ||
Duration.prototype.ceil = function (date, timezone) { | ||
var floored = this.floor(date, timezone); | ||
if (floored.valueOf() === date.valueOf()) | ||
return date; | ||
return this.shift(floored, timezone, 1); | ||
}; | ||
Duration.prototype.shift = function (date, timezone, step) { | ||
@@ -231,0 +237,0 @@ if (step === void 0) { step = 1; } |
{ | ||
"name": "chronoshift", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"description": "A tiny library for shifting time with timezones", | ||
@@ -46,3 +46,3 @@ "keywords": [ | ||
"volta": { | ||
"node": "12.22.10" | ||
"node": "14.21.3" | ||
}, | ||
@@ -49,0 +49,0 @@ "jest": { |
@@ -293,2 +293,13 @@ /* | ||
/** | ||
* Ceilings the date according to this duration | ||
* @param date The date to ceiling | ||
* @param timezone The timezone within which to ceiling | ||
*/ | ||
public ceil(date: Date, timezone: Timezone): Date { | ||
const floored = this.floor(date, timezone); | ||
if (floored.valueOf() === date.valueOf()) return date; // Just like ceil(3) is 3 and not 4 | ||
return this.shift(floored, timezone, 1); | ||
} | ||
/** | ||
* Moves the given date by 'step' times of the duration | ||
@@ -295,0 +306,0 @@ * Negative step value will move back in time. |
@@ -32,2 +32,3 @@ import type { Instance } from 'immutable-class'; | ||
floor(date: Date, timezone: Timezone): Date; | ||
ceil(date: Date, timezone: Timezone): Date; | ||
shift(date: Date, timezone: Timezone, step?: number): Date; | ||
@@ -34,0 +35,0 @@ materialize(start: Date, end: Date, timezone: Timezone, step?: number): Date[]; |
Sorry, the diff of this file is not supported yet
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
116214
2833