ical-generator 7.0.0-develop.1 → 7.0.0-develop.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/event.ts +12 -8
package/package.json
CHANGED
package/src/event.ts
CHANGED
|
@@ -360,16 +360,11 @@ export default class ICalEvent {
|
|
|
360
360
|
start(start: ICalDateTimeValue): this;
|
|
361
361
|
start(start?: ICalDateTimeValue): this | ICalDateTimeValue {
|
|
362
362
|
if (start === undefined) {
|
|
363
|
+
this.swapStartAndEndIfRequired();
|
|
363
364
|
return this.data.start;
|
|
364
365
|
}
|
|
365
366
|
|
|
366
367
|
this.data.start = checkDate(start, 'start');
|
|
367
|
-
if (this.data.start && this.data.end && toDate(this.data.start).getTime() > toDate(this.data.end).getTime()) {
|
|
368
|
-
const t = this.data.start;
|
|
369
|
-
this.data.start = this.data.end;
|
|
370
|
-
this.data.end = t;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
368
|
return this;
|
|
374
369
|
}
|
|
375
370
|
|
|
@@ -391,6 +386,7 @@ export default class ICalEvent {
|
|
|
391
386
|
end(end: ICalDateTimeValue | null): this;
|
|
392
387
|
end(end?: ICalDateTimeValue | null): this | ICalDateTimeValue | null {
|
|
393
388
|
if (end === undefined) {
|
|
389
|
+
this.swapStartAndEndIfRequired();
|
|
394
390
|
return this.data.end;
|
|
395
391
|
}
|
|
396
392
|
if (end === null) {
|
|
@@ -399,13 +395,19 @@ export default class ICalEvent {
|
|
|
399
395
|
}
|
|
400
396
|
|
|
401
397
|
this.data.end = checkDate(end, 'end');
|
|
398
|
+
return this;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Checks if the start date is after the end date and swaps them if necessary.
|
|
403
|
+
* @private
|
|
404
|
+
*/
|
|
405
|
+
private swapStartAndEndIfRequired(): void {
|
|
402
406
|
if (this.data.start && this.data.end && toDate(this.data.start).getTime() > toDate(this.data.end).getTime()) {
|
|
403
407
|
const t = this.data.start;
|
|
404
408
|
this.data.start = this.data.end;
|
|
405
409
|
this.data.end = t;
|
|
406
410
|
}
|
|
407
|
-
|
|
408
|
-
return this;
|
|
409
411
|
}
|
|
410
412
|
|
|
411
413
|
/**
|
|
@@ -1629,6 +1631,7 @@ export default class ICalEvent {
|
|
|
1629
1631
|
});
|
|
1630
1632
|
}
|
|
1631
1633
|
|
|
1634
|
+
this.swapStartAndEndIfRequired();
|
|
1632
1635
|
return Object.assign({}, this.data, {
|
|
1633
1636
|
start: toJSON(this.data.start) || null,
|
|
1634
1637
|
end: toJSON(this.data.end) || null,
|
|
@@ -1660,6 +1663,7 @@ export default class ICalEvent {
|
|
|
1660
1663
|
// SEQUENCE
|
|
1661
1664
|
g += 'SEQUENCE:' + this.data.sequence + '\r\n';
|
|
1662
1665
|
|
|
1666
|
+
this.swapStartAndEndIfRequired();
|
|
1663
1667
|
g += 'DTSTAMP:' + formatDate(this.calendar.timezone(), this.data.stamp) + '\r\n';
|
|
1664
1668
|
if (this.data.allDay) {
|
|
1665
1669
|
g += 'DTSTART;VALUE=DATE:' + formatDate(this.calendar.timezone(), this.data.start, true) + '\r\n';
|