@rschedule/moment-tz-date-adapter
Advanced tools
Comparing version 0.10.0 to 0.11.0-alpha.2
@@ -93,2 +93,14 @@ (function (global, factory) { | ||
}; | ||
Object.defineProperty(MomentTZDateAdapter.prototype, "end", { | ||
get: function () { | ||
if (!this.duration) | ||
return; | ||
if (this._end) | ||
return this._end; | ||
this._end = MomentTZDateAdapter.fromDateTime(this.toDateTime().add(this.duration, 'millisecond')).date; | ||
return this._end; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
MomentTZDateAdapter.prototype.set = function (_, value) { | ||
@@ -117,5 +129,4 @@ if (this.timezone === value) | ||
MomentTZDateAdapter.prototype.toJSON = function () { | ||
return { | ||
var json = { | ||
timezone: this.timezone, | ||
duration: this.duration, | ||
year: this.date.get('year'), | ||
@@ -129,2 +140,6 @@ month: this.date.get('month') + 1, | ||
}; | ||
if (this.duration) { | ||
json.duration = this.duration; | ||
} | ||
return json; | ||
}; | ||
@@ -131,0 +146,0 @@ MomentTZDateAdapter.prototype.assertIsValid = function () { |
@@ -57,2 +57,10 @@ import { DateAdapter, DateTime, InvalidDateAdapterError } from '@rschedule/rschedule'; | ||
} | ||
get end() { | ||
if (!this.duration) | ||
return; | ||
if (this._end) | ||
return this._end; | ||
this._end = MomentTZDateAdapter.fromDateTime(this.toDateTime().add(this.duration, 'millisecond')).date; | ||
return this._end; | ||
} | ||
set(_, value) { | ||
@@ -81,5 +89,4 @@ if (this.timezone === value) | ||
toJSON() { | ||
return { | ||
const json = { | ||
timezone: this.timezone, | ||
duration: this.duration, | ||
year: this.date.get('year'), | ||
@@ -93,2 +100,6 @@ month: this.date.get('month') + 1, | ||
}; | ||
if (this.duration) { | ||
json.duration = this.duration; | ||
} | ||
return json; | ||
} | ||
@@ -95,0 +106,0 @@ assertIsValid() { |
@@ -1,2 +0,2 @@ | ||
import { DateAdapter, DateTime, IDateAdapter, OccurrenceGenerator } from '@rschedule/rschedule'; | ||
import { DateAdapter, DateTime, IDateAdapter } from '@rschedule/rschedule'; | ||
import moment from 'moment-timezone'; | ||
@@ -19,3 +19,3 @@ declare const MOMENT_TZ_DATE_ADAPTER_ID: unique symbol; | ||
*/ | ||
static isInstance(object: any): object is MomentTZDateAdapter; | ||
static isInstance(object: unknown): object is MomentTZDateAdapter; | ||
/** | ||
@@ -30,7 +30,9 @@ * Checks if object is an instance of `DateTime` | ||
readonly duration: number | undefined; | ||
readonly generators: OccurrenceGenerator<typeof MomentTZDateAdapter>[]; | ||
readonly generators: unknown[]; | ||
protected readonly [MOMENT_TZ_DATE_ADAPTER_ID] = true; | ||
private _end; | ||
constructor(date: moment.Moment, options?: { | ||
duration?: number; | ||
}); | ||
readonly end: moment.Moment | undefined; | ||
set(_: 'timezone', value: string | null): MomentTZDateAdapter; | ||
@@ -37,0 +39,0 @@ valueOf(): number; |
{ | ||
"name": "@rschedule/moment-tz-date-adapter", | ||
"version": "0.10.0", | ||
"version": "0.11.0-alpha.2+0e28b84", | ||
"description": "An rSchedule DateAdapter for \"moment-timezone\" date objects.", | ||
@@ -15,13 +15,8 @@ "author": "John Carroll <john.carroll.p@gmail.com>", | ||
"rschedule", | ||
"dates", | ||
"momentjs", | ||
"moment", | ||
"moment-timezone", | ||
"javascript", | ||
"typescript", | ||
"recurring", | ||
"events", | ||
"dates", | ||
"recurrences", | ||
"calendar", | ||
"icalendar", | ||
"rfc" | ||
"typescript" | ||
], | ||
@@ -48,3 +43,3 @@ "main": "build/main.js", | ||
}, | ||
"gitHead": "1e5726f685afd00c0d86f92d477bfe28299784d1" | ||
"gitHead": "0e28b848d0d8b3b7158159156578966066f47b0f" | ||
} |
@@ -28,3 +28,3 @@ import { | ||
*/ | ||
static isInstance(object: any): object is MomentTZDateAdapter { | ||
static isInstance(object: unknown): object is MomentTZDateAdapter { | ||
return !!(super.isInstance(object) && (object as any)[MOMENT_TZ_DATE_ADAPTER_ID]); | ||
@@ -66,6 +66,8 @@ } | ||
readonly duration: number | undefined; | ||
readonly generators: OccurrenceGenerator<typeof MomentTZDateAdapter>[] = []; | ||
readonly generators: unknown[] = []; | ||
protected readonly [MOMENT_TZ_DATE_ADAPTER_ID] = true; | ||
private _end: moment.Moment | undefined; | ||
constructor(date: moment.Moment, options: { duration?: number } = {}) { | ||
@@ -81,2 +83,14 @@ super(undefined); | ||
get end(): moment.Moment | undefined { | ||
if (!this.duration) return; | ||
if (this._end) return this._end; | ||
this._end = MomentTZDateAdapter.fromDateTime( | ||
this.toDateTime().add(this.duration, 'millisecond'), | ||
).date; | ||
return this._end; | ||
} | ||
set(_: 'timezone', value: string | null) { | ||
@@ -110,5 +124,4 @@ if (this.timezone === value) return this; | ||
toJSON(): IDateAdapter.JSON { | ||
return { | ||
const json: IDateAdapter.JSON = { | ||
timezone: this.timezone, | ||
duration: this.duration, | ||
year: this.date.get('year'), | ||
@@ -122,2 +135,8 @@ month: this.date.get('month') + 1, | ||
}; | ||
if (this.duration) { | ||
json.duration = this.duration; | ||
} | ||
return json; | ||
} | ||
@@ -124,0 +143,0 @@ |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
21872
511
1