iamcal 2.0.0 → 2.1.1
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/README.md +47 -11
- package/lib/component.d.ts +46 -9
- package/lib/component.d.ts.map +1 -1
- package/lib/component.js +105 -17
- package/lib/components/Calendar.d.ts +35 -14
- package/lib/components/Calendar.d.ts.map +1 -1
- package/lib/components/Calendar.js +43 -15
- package/lib/components/CalendarEvent.d.ts +84 -22
- package/lib/components/CalendarEvent.d.ts.map +1 -1
- package/lib/components/CalendarEvent.js +142 -67
- package/lib/components/TimeZone.d.ts +62 -39
- package/lib/components/TimeZone.d.ts.map +1 -1
- package/lib/components/TimeZone.js +81 -86
- package/lib/components/TimeZoneOffset.d.ts +103 -0
- package/lib/components/TimeZoneOffset.d.ts.map +1 -0
- package/lib/components/TimeZoneOffset.js +148 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +2 -1
- package/lib/date.d.ts +165 -0
- package/lib/date.d.ts.map +1 -0
- package/lib/date.js +373 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -2
- package/lib/io.d.ts +9 -7
- package/lib/io.d.ts.map +1 -1
- package/lib/io.js +16 -11
- package/lib/parse.d.ts +32 -15
- package/lib/parse.d.ts.map +1 -1
- package/lib/parse.js +55 -53
- package/lib/patterns.d.ts +36 -0
- package/lib/patterns.d.ts.map +1 -0
- package/lib/patterns.js +50 -0
- package/lib/property.d.ts +149 -0
- package/lib/property.d.ts.map +1 -0
- package/lib/property.js +450 -0
- package/package.json +50 -38
- package/src/component.ts +132 -23
- package/src/components/Calendar.ts +58 -20
- package/src/components/CalendarEvent.ts +170 -66
- package/src/components/TimeZone.ts +86 -96
- package/src/components/TimeZoneOffset.ts +187 -0
- package/src/components/index.ts +2 -1
- package/src/date.ts +395 -0
- package/src/index.ts +3 -1
- package/src/io.ts +16 -11
- package/src/parse.ts +71 -51
- package/src/patterns.ts +69 -0
- package/src/property.ts +492 -0
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TimeZone = void 0;
|
|
4
4
|
const component_1 = require("../component");
|
|
5
|
-
const
|
|
5
|
+
const date_1 = require("../date");
|
|
6
|
+
const TimeZoneOffset_1 = require("./TimeZoneOffset");
|
|
6
7
|
/**
|
|
7
8
|
* Represents a VTIMEZONE component, containing time zone definitions.
|
|
8
9
|
*/
|
|
9
10
|
class TimeZone extends component_1.Component {
|
|
11
|
+
name = 'VTIMEZONE';
|
|
10
12
|
constructor(a) {
|
|
11
|
-
|
|
13
|
+
let component;
|
|
12
14
|
if (a instanceof component_1.Component) {
|
|
13
15
|
component = a;
|
|
16
|
+
TimeZone.prototype.validate.call(component);
|
|
14
17
|
}
|
|
15
18
|
else {
|
|
16
19
|
const tzid = a;
|
|
@@ -19,25 +22,31 @@ class TimeZone extends component_1.Component {
|
|
|
19
22
|
}
|
|
20
23
|
super(component.name, component.properties, component.components);
|
|
21
24
|
}
|
|
22
|
-
|
|
25
|
+
validate() {
|
|
26
|
+
if (this.name !== 'VTIMEZONE')
|
|
27
|
+
throw new component_1.ComponentValidationError('Component name must be VEVENT');
|
|
28
|
+
const requiredProperties = ['TZID'];
|
|
29
|
+
this.validateAllProperties(requiredProperties);
|
|
30
|
+
}
|
|
31
|
+
getId() {
|
|
23
32
|
return this.getProperty('TZID').value;
|
|
24
33
|
}
|
|
25
34
|
setId(value) {
|
|
26
35
|
return this.setProperty('TZID', value);
|
|
27
36
|
}
|
|
28
|
-
|
|
29
|
-
const text = this.getProperty('LAST-
|
|
37
|
+
getLastModified() {
|
|
38
|
+
const text = this.getProperty('LAST-MODIFIED');
|
|
30
39
|
if (!text)
|
|
31
40
|
return;
|
|
32
|
-
return (0,
|
|
41
|
+
return (0, date_1.parseDateProperty)(text);
|
|
33
42
|
}
|
|
34
|
-
|
|
35
|
-
return this.setProperty('LAST-
|
|
43
|
+
setLastModified(value) {
|
|
44
|
+
return this.setProperty('LAST-MODIFIED', value.toISOString());
|
|
36
45
|
}
|
|
37
|
-
|
|
46
|
+
removeLastModified() {
|
|
38
47
|
this.removePropertiesWithName('LAST-MOD');
|
|
39
48
|
}
|
|
40
|
-
|
|
49
|
+
getUrl() {
|
|
41
50
|
return this.getProperty('TZURL')?.value;
|
|
42
51
|
}
|
|
43
52
|
setUrl(value) {
|
|
@@ -46,87 +55,73 @@ class TimeZone extends component_1.Component {
|
|
|
46
55
|
removeUrl() {
|
|
47
56
|
this.removePropertiesWithName('TZURL');
|
|
48
57
|
}
|
|
49
|
-
/**
|
|
50
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Get all time offsets.
|
|
60
|
+
* @returns An array of time zone offsets defined in this time zone.
|
|
61
|
+
*/
|
|
62
|
+
getOffsets() {
|
|
51
63
|
const offsets = [];
|
|
52
64
|
this.components.forEach(component => {
|
|
53
|
-
if (component.name === 'STANDARD' ||
|
|
54
|
-
|
|
65
|
+
if (component.name === 'STANDARD' ||
|
|
66
|
+
component.name === 'DAYLIGHT') {
|
|
67
|
+
offsets.push(new TimeZoneOffset_1.TimeZoneOffset(component));
|
|
55
68
|
}
|
|
56
69
|
});
|
|
57
70
|
return offsets;
|
|
58
71
|
}
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Get standard/winter time offsets.
|
|
74
|
+
* @returns An array of time zone offsets defined in this time zone that are of type STANDARD.
|
|
75
|
+
*/
|
|
76
|
+
getStandardOffsets() {
|
|
77
|
+
return this.getComponentsWithName('STANDARD').map(c => new TimeZoneOffset_1.TimeZoneOffset(c));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get daylight savings time offsets.
|
|
81
|
+
* @returns An array of time zone offsets defined in this time zone that are of type DAYLIGHT.
|
|
82
|
+
*/
|
|
83
|
+
getDaylightOffsets() {
|
|
84
|
+
return this.getComponentsWithName('DAYLIGHT').map(c => new TimeZoneOffset_1.TimeZoneOffset(c));
|
|
85
|
+
}
|
|
86
|
+
/* eslint-disable */
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Use {@link getId} instead.
|
|
89
|
+
*/
|
|
90
|
+
id = this.getId;
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Use {@link getLastModified} instead.
|
|
93
|
+
*/
|
|
94
|
+
lastMod = this.getLastModified;
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated Use {@link setLastModified} instead.
|
|
97
|
+
*/
|
|
98
|
+
setLastMod = this.setLastModified;
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated Use {@link removeLastModified} instead.
|
|
101
|
+
*/
|
|
102
|
+
removeLastMod = this.removeLastModified;
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated Use {@link getUrl} instead.
|
|
105
|
+
*/
|
|
106
|
+
url = this.getUrl;
|
|
107
|
+
/**
|
|
108
|
+
* Get all time offsets.
|
|
109
|
+
* @returns An array of time zone offsets defined in this time zone.
|
|
110
|
+
* @deprecated Use {@link getOffsets} instead.
|
|
111
|
+
*/
|
|
112
|
+
offsets = this.getOffsets;
|
|
113
|
+
/**
|
|
114
|
+
* Get standard/winter time offsets.
|
|
115
|
+
* @returns An array of time zone offsets defined in this time zone that are of type STANDARD.
|
|
116
|
+
* @deprecated Use {@link getStandardOffsets} instead.
|
|
117
|
+
*/
|
|
118
|
+
standardOffsets = this.getStandardOffsets;
|
|
119
|
+
/**
|
|
120
|
+
* Get daylight savings time offsets.
|
|
121
|
+
* @returns An array of time zone offsets defined in this time zone that are of type DAYLIGHT.
|
|
122
|
+
* @deprecated Use {@link getDaylightOffsets} instead.
|
|
123
|
+
*/
|
|
124
|
+
daylightOffsets = this.getDaylightOffsets;
|
|
67
125
|
}
|
|
68
126
|
exports.TimeZone = TimeZone;
|
|
69
|
-
|
|
70
|
-
class TimeZoneOffset extends component_1.Component {
|
|
71
|
-
constructor(a, b, c, d) {
|
|
72
|
-
var component;
|
|
73
|
-
if (a instanceof component_1.Component) {
|
|
74
|
-
component = a;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
const name = a;
|
|
78
|
-
const start = b;
|
|
79
|
-
const offsetFrom = c;
|
|
80
|
-
const offsetTo = d;
|
|
81
|
-
component = new component_1.Component(name);
|
|
82
|
-
component.setProperty('DTSTART', (0, parse_1.toDateTimeString)(start));
|
|
83
|
-
component.setProperty('TZOFFSETFROM', offsetFrom);
|
|
84
|
-
component.setProperty('TZOFFSETTO', offsetTo);
|
|
85
|
-
}
|
|
86
|
-
super(component.name, component.properties, component.components);
|
|
87
|
-
}
|
|
88
|
-
start() {
|
|
89
|
-
return (0, parse_1.parseDate)(this.getProperty('DTSTART'));
|
|
90
|
-
}
|
|
91
|
-
setStart(value, fullDay = false) {
|
|
92
|
-
if (fullDay) {
|
|
93
|
-
this.setProperty('DTSTART', (0, parse_1.toDateString)(value));
|
|
94
|
-
this.setPropertyParams('DTSTART', ['VALUE=DATE']);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
this.setProperty('DTSTART', (0, parse_1.toDateTimeString)(value));
|
|
98
|
-
}
|
|
99
|
-
return this;
|
|
100
|
-
}
|
|
101
|
-
offsetFrom() {
|
|
102
|
-
return this.getProperty('TZOFFSETFROM').value;
|
|
103
|
-
}
|
|
104
|
-
setOffsetFrom(value) {
|
|
105
|
-
return this.setProperty('TZOFFSETFROM', value);
|
|
106
|
-
}
|
|
107
|
-
offsetTo() {
|
|
108
|
-
return this.getProperty('TZOFFSETTO').value;
|
|
109
|
-
}
|
|
110
|
-
setOffsetTo(value) {
|
|
111
|
-
return this.setProperty('TZOFFSETTO', value);
|
|
112
|
-
}
|
|
113
|
-
comment() {
|
|
114
|
-
return this.getProperty('COMMENT')?.value;
|
|
115
|
-
}
|
|
116
|
-
setComment(value) {
|
|
117
|
-
return this.setProperty('COMMENT', value);
|
|
118
|
-
}
|
|
119
|
-
removeComment() {
|
|
120
|
-
this.removePropertiesWithName('COMMENT');
|
|
121
|
-
}
|
|
122
|
-
timeZoneName() {
|
|
123
|
-
return this.getProperty('TZNAME')?.value;
|
|
124
|
-
}
|
|
125
|
-
setTimeZoneName(value) {
|
|
126
|
-
return this.setProperty('TZNAME', value);
|
|
127
|
-
}
|
|
128
|
-
removeTimeZoneName() {
|
|
129
|
-
this.removePropertiesWithName('TZNAME');
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVGltZVpvbmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29tcG9uZW50cy9UaW1lWm9uZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSw0Q0FBd0M7QUFDeEMsb0NBQW9FO0FBRXBFOztHQUVHO0FBQ0gsTUFBYSxRQUFTLFNBQVEscUJBQVM7SUFHbkMsWUFBWSxDQUFxQjtRQUM3QixJQUFJLFNBQW9CLENBQUE7UUFDeEIsSUFBSSxDQUFDLFlBQVkscUJBQVMsRUFBRSxDQUFDO1lBQ3pCLFNBQVMsR0FBRyxDQUFjLENBQUE7UUFDOUIsQ0FBQzthQUFNLENBQUM7WUFDSixNQUFNLElBQUksR0FBRyxDQUFXLENBQUE7WUFDeEIsU0FBUyxHQUFHLElBQUkscUJBQVMsQ0FBQyxXQUFXLENBQUMsQ0FBQTtZQUN0QyxTQUFTLENBQUMsV0FBVyxDQUFDLE1BQU0sRUFBRSxJQUFJLENBQUMsQ0FBQTtRQUN2QyxDQUFDO1FBQ0QsS0FBSyxDQUFDLFNBQVMsQ0FBQyxJQUFJLEVBQUUsU0FBUyxDQUFDLFVBQVUsRUFBRSxTQUFTLENBQUMsVUFBVSxDQUFDLENBQUE7SUFDckUsQ0FBQztJQUVELEVBQUU7UUFD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Q0FBQTtJQUVqQzs7T0FFRztJQUNILGFBQWEsR0FBRyxJQUFJLENBQUMsa0JBQWtCLENBQUE7SUFFdkM7O09BRUc7SUFDSCxHQUFHLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQTtJQUVqQjs7OztPQUlHO0lBQ0gsT0FBTyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUE7SUFFekI7Ozs7T0FJRztJQUNILGVBQWUsR0FBRyxJQUFJLENBQUMsa0JBQWtCLENBQUE7SUFFekM7Ozs7T0FJRztJQUNILGVBQWUsR0FBRyxJQUFJLENBQUMsa0JBQWtCLENBQUE7Q0FDNUM7QUEvSUQsNEJBK0lDIn0=
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Component } from '../component';
|
|
2
|
+
import { CalendarDateOrTime } from '../date';
|
|
3
|
+
export declare const knownOffsetTypes: string[];
|
|
4
|
+
export type OffsetType = (typeof knownOffsetTypes)[number];
|
|
5
|
+
type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
6
|
+
export type Offset = `${'-' | '+'}${Digit}${Digit}${Digit}${Digit}`;
|
|
7
|
+
/**
|
|
8
|
+
* Represents a STANDARD or DAYLIGHT subcomponent, defining a time zone offset.
|
|
9
|
+
*/
|
|
10
|
+
export declare class TimeZoneOffset extends Component {
|
|
11
|
+
/**
|
|
12
|
+
* @param type If this is a STANDARD or DAYLIGHT component.
|
|
13
|
+
* @param start From when this offset is active.
|
|
14
|
+
* @param offsetFrom The offset that is in use prior to this time zone observance.
|
|
15
|
+
* @param offsetTo The offset that is in use during this time zone observance.
|
|
16
|
+
*/
|
|
17
|
+
constructor(type: OffsetType, start: CalendarDateOrTime | Date, offsetFrom: Offset, offsetTo: Offset);
|
|
18
|
+
constructor(component: Component);
|
|
19
|
+
validate(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get the date or time when this time zone offset starts.
|
|
22
|
+
* @returns The start date or time of this time zone offset.
|
|
23
|
+
*/
|
|
24
|
+
getStart(): CalendarDateOrTime;
|
|
25
|
+
/**
|
|
26
|
+
* Set the date or time when this time zone offset starts.
|
|
27
|
+
* @param value The start date or time.
|
|
28
|
+
* @returns The TimeZoneOffset instance for chaining.
|
|
29
|
+
*/
|
|
30
|
+
setStart(value: CalendarDateOrTime | Date): this;
|
|
31
|
+
/**
|
|
32
|
+
* Get the offset which is offset from during this time zone offset.
|
|
33
|
+
* @returns The offset in a format such as "+0100" or "-0230".
|
|
34
|
+
*/
|
|
35
|
+
getOffsetFrom(): Offset;
|
|
36
|
+
/**
|
|
37
|
+
* Set the offset to offset from during this time zone offset.
|
|
38
|
+
* @param value An offset such as "+0100" or "-0230".
|
|
39
|
+
* @returns The TimeZoneOffset instance for chaining.
|
|
40
|
+
*/
|
|
41
|
+
setOffsetFrom(value: Offset): this;
|
|
42
|
+
/**
|
|
43
|
+
* Get the offset which is offset to during this time zone offset.
|
|
44
|
+
* @returns The offset in a format such as "+0100" or "-0230".
|
|
45
|
+
*/
|
|
46
|
+
getOffsetTo(): Offset;
|
|
47
|
+
/**
|
|
48
|
+
* Set the offset to offset to during this time zone offset.
|
|
49
|
+
* @param value An offset such as "+0100" or "-0230".
|
|
50
|
+
* @returns The TimeZoneOffset instance for chaining.
|
|
51
|
+
*/
|
|
52
|
+
setOffsetTo(value: Offset): this;
|
|
53
|
+
getComment(): string | undefined;
|
|
54
|
+
setComment(value: string): this;
|
|
55
|
+
removeComment(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Get the name of this time zone offset.
|
|
58
|
+
* @returns The time zone offset name if it exists.
|
|
59
|
+
*/
|
|
60
|
+
getTimeZoneName(): string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Set the name of this time zone offset.
|
|
63
|
+
* @param value The new name.
|
|
64
|
+
* @returns The TimeZoneOffset instance for chaining.
|
|
65
|
+
* @example
|
|
66
|
+
* timeZoneOffset.setTimeZoneName('EST')
|
|
67
|
+
*/
|
|
68
|
+
setTimeZoneName(value: string): this;
|
|
69
|
+
/**
|
|
70
|
+
* Remove the name of this time zone offset.
|
|
71
|
+
*/
|
|
72
|
+
removeTimeZoneName(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Get the date or time when this time zone offset starts.
|
|
75
|
+
* @returns The start date or time of this time zone offset.
|
|
76
|
+
* @deprecated Use {@link getStart} instead.
|
|
77
|
+
*/
|
|
78
|
+
start: () => CalendarDateOrTime;
|
|
79
|
+
/**
|
|
80
|
+
* Get the offset which is offset from during this time zone offset.
|
|
81
|
+
* @returns The offset in a format such as "+0100" or "-0230".
|
|
82
|
+
* @deprecated Use {@link getOffsetFrom} instead.
|
|
83
|
+
*/
|
|
84
|
+
offsetFrom: () => Offset;
|
|
85
|
+
/**
|
|
86
|
+
* Get the offset which is offset to during this time zone offset.
|
|
87
|
+
* @returns The offset in a format such as "+0100" or "-0230".
|
|
88
|
+
* @deprecated Use {@link getOffsetTo} instead.
|
|
89
|
+
*/
|
|
90
|
+
offsetTo: () => Offset;
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Use {@link getComment} instead.
|
|
93
|
+
*/
|
|
94
|
+
comment: () => string | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Get the name of this time zone offset.
|
|
97
|
+
* @returns The time zone offset name if it exists.
|
|
98
|
+
* @deprecated Use {@link getTimeZoneName} instead.
|
|
99
|
+
*/
|
|
100
|
+
timeZoneName: () => string | undefined;
|
|
101
|
+
}
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=TimeZoneOffset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeZoneOffset.d.ts","sourceRoot":"","sources":["../../src/components/TimeZoneOffset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA4B,MAAM,cAAc,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAkC,MAAM,SAAS,CAAA;AAG5E,eAAO,MAAM,gBAAgB,UAA2B,CAAA;AACxD,MAAM,MAAM,UA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ACH,QAAQ,QAxEO,MAAM,CAwEM;IAE3B;;OAEG;IACH,OAAO,QAhEO,MAAM,GAAG,SAAS,CAgEP;IAEzB;;;;OAIG;IACH,YAAY,QAvDO,MAAM,GAAG,SAAS,CAuDF;CACtC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeZoneOffset = exports.knownOffsetTypes = void 0;
|
|
4
|
+
const component_1 = require("../component");
|
|
5
|
+
const date_1 = require("../date");
|
|
6
|
+
exports.knownOffsetTypes = ['DAYLIGHT', 'STANDARD'];
|
|
7
|
+
/**
|
|
8
|
+
* Represents a STANDARD or DAYLIGHT subcomponent, defining a time zone offset.
|
|
9
|
+
*/
|
|
10
|
+
class TimeZoneOffset extends component_1.Component {
|
|
11
|
+
constructor(a, b, c, d) {
|
|
12
|
+
let component;
|
|
13
|
+
if (a instanceof component_1.Component) {
|
|
14
|
+
component = a;
|
|
15
|
+
TimeZoneOffset.prototype.validate.call(component);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const name = a;
|
|
19
|
+
const start = (0, date_1.convertDate)(b);
|
|
20
|
+
const offsetFrom = c;
|
|
21
|
+
const offsetTo = d;
|
|
22
|
+
component = new component_1.Component(name);
|
|
23
|
+
component.setProperty('DTSTART', start);
|
|
24
|
+
component.setProperty('TZOFFSETFROM', offsetFrom);
|
|
25
|
+
component.setProperty('TZOFFSETTO', offsetTo);
|
|
26
|
+
}
|
|
27
|
+
super(component.name, component.properties, component.components);
|
|
28
|
+
}
|
|
29
|
+
validate() {
|
|
30
|
+
if (!exports.knownOffsetTypes.includes(this.name)) {
|
|
31
|
+
throw new component_1.ComponentValidationError('Component name must be STANDARD or DAYLIGHT');
|
|
32
|
+
}
|
|
33
|
+
const requiredProperties = [
|
|
34
|
+
'DTSTART',
|
|
35
|
+
'TZOFFSETFROM',
|
|
36
|
+
'TZOFFSETTO',
|
|
37
|
+
];
|
|
38
|
+
this.validateAllProperties(requiredProperties);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the date or time when this time zone offset starts.
|
|
42
|
+
* @returns The start date or time of this time zone offset.
|
|
43
|
+
*/
|
|
44
|
+
getStart() {
|
|
45
|
+
return (0, date_1.parseDateProperty)(this.getProperty('DTSTART'));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Set the date or time when this time zone offset starts.
|
|
49
|
+
* @param value The start date or time.
|
|
50
|
+
* @returns The TimeZoneOffset instance for chaining.
|
|
51
|
+
*/
|
|
52
|
+
setStart(value) {
|
|
53
|
+
return this.setProperty('DTSTART', (0, date_1.convertDate)(value));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the offset which is offset from during this time zone offset.
|
|
57
|
+
* @returns The offset in a format such as "+0100" or "-0230".
|
|
58
|
+
*/
|
|
59
|
+
getOffsetFrom() {
|
|
60
|
+
return this.getProperty('TZOFFSETFROM').value;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Set the offset to offset from during this time zone offset.
|
|
64
|
+
* @param value An offset such as "+0100" or "-0230".
|
|
65
|
+
* @returns The TimeZoneOffset instance for chaining.
|
|
66
|
+
*/
|
|
67
|
+
setOffsetFrom(value) {
|
|
68
|
+
return this.setProperty('TZOFFSETFROM', value);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get the offset which is offset to during this time zone offset.
|
|
72
|
+
* @returns The offset in a format such as "+0100" or "-0230".
|
|
73
|
+
*/
|
|
74
|
+
getOffsetTo() {
|
|
75
|
+
return this.getProperty('TZOFFSETTO').value;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Set the offset to offset to during this time zone offset.
|
|
79
|
+
* @param value An offset such as "+0100" or "-0230".
|
|
80
|
+
* @returns The TimeZoneOffset instance for chaining.
|
|
81
|
+
*/
|
|
82
|
+
setOffsetTo(value) {
|
|
83
|
+
return this.setProperty('TZOFFSETTO', value);
|
|
84
|
+
}
|
|
85
|
+
getComment() {
|
|
86
|
+
return this.getProperty('COMMENT')?.value;
|
|
87
|
+
}
|
|
88
|
+
setComment(value) {
|
|
89
|
+
return this.setProperty('COMMENT', value);
|
|
90
|
+
}
|
|
91
|
+
removeComment() {
|
|
92
|
+
this.removePropertiesWithName('COMMENT');
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the name of this time zone offset.
|
|
96
|
+
* @returns The time zone offset name if it exists.
|
|
97
|
+
*/
|
|
98
|
+
getTimeZoneName() {
|
|
99
|
+
return this.getProperty('TZNAME')?.value;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Set the name of this time zone offset.
|
|
103
|
+
* @param value The new name.
|
|
104
|
+
* @returns The TimeZoneOffset instance for chaining.
|
|
105
|
+
* @example
|
|
106
|
+
* timeZoneOffset.setTimeZoneName('EST')
|
|
107
|
+
*/
|
|
108
|
+
setTimeZoneName(value) {
|
|
109
|
+
return this.setProperty('TZNAME', value);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Remove the name of this time zone offset.
|
|
113
|
+
*/
|
|
114
|
+
removeTimeZoneName() {
|
|
115
|
+
this.removePropertiesWithName('TZNAME');
|
|
116
|
+
}
|
|
117
|
+
/* eslint-disable */
|
|
118
|
+
/**
|
|
119
|
+
* Get the date or time when this time zone offset starts.
|
|
120
|
+
* @returns The start date or time of this time zone offset.
|
|
121
|
+
* @deprecated Use {@link getStart} instead.
|
|
122
|
+
*/
|
|
123
|
+
start = this.getStart;
|
|
124
|
+
/**
|
|
125
|
+
* Get the offset which is offset from during this time zone offset.
|
|
126
|
+
* @returns The offset in a format such as "+0100" or "-0230".
|
|
127
|
+
* @deprecated Use {@link getOffsetFrom} instead.
|
|
128
|
+
*/
|
|
129
|
+
offsetFrom = this.getOffsetFrom;
|
|
130
|
+
/**
|
|
131
|
+
* Get the offset which is offset to during this time zone offset.
|
|
132
|
+
* @returns The offset in a format such as "+0100" or "-0230".
|
|
133
|
+
* @deprecated Use {@link getOffsetTo} instead.
|
|
134
|
+
*/
|
|
135
|
+
offsetTo = this.getOffsetTo;
|
|
136
|
+
/**
|
|
137
|
+
* @deprecated Use {@link getComment} instead.
|
|
138
|
+
*/
|
|
139
|
+
comment = this.getComment;
|
|
140
|
+
/**
|
|
141
|
+
* Get the name of this time zone offset.
|
|
142
|
+
* @returns The time zone offset name if it exists.
|
|
143
|
+
* @deprecated Use {@link getTimeZoneName} instead.
|
|
144
|
+
*/
|
|
145
|
+
timeZoneName = this.getTimeZoneName;
|
|
146
|
+
}
|
|
147
|
+
exports.TimeZoneOffset = TimeZoneOffset;
|
|
148
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVGltZVpvbmVPZmZzZXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29tcG9uZW50cy9UaW1lWm9uZU9mZnNldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSw0Q0FBa0U7QUFDbEUsa0NBQTRFO0FBRy9ELFFBQUEsZ0JBQWdCLEdBQUcsQ0FBQyxVQUFVLEVBQUUsVUFBVSxDQUFDLENBQUE7QUFLeEQ7O0dBRUc7QUFDSCxNQUFhLGNBQWUsU0FBUSxxQkFBUztJQWN6QyxZQUNJLENBQXlCLEVBQ3pCLENBQTZCLEVBQzdCLENBQVUsRUFDVixDQUFVO1FBRVYsSUFBSSxTQUFvQixDQUFBO1FBQ3hCLElBQUksQ0FBQyxZQUFZLHFCQUFTLEVBQUUsQ0FBQztZQUN6QixTQUFTLEdBQUcsQ0FBYyxDQUFBO1lBQzFCLGNBQWMsQ0FBQyxTQUFTLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtRQUNyRCxDQUFDO2FBQU0sQ0FBQztZQUNKLE1BQU0sSUFBSSxHQUFHLENBQWUsQ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BQUMsRUFBRSxLQUFLLENBQUE7SUFDNUMsQ0FBQztJQUVEOzs7Ozs7T0FNRztJQUNILGVBQWUsQ0FBQyxLQUFhO1FBQ3pCLE9BQU8sSUFBSSxDQUFDLFdBQVcsQ0FBQyxRQUFRLEVBQUUsS0FBSyxDQUFDLENBQUE7SUFDNUMsQ0FBQztJQUVEOztPQUVHO0lBQ0gsa0JBQWtCO1FBQ2QsSUFBSSxDQUFDLHdCQUF3QixDQUFDLFFBQVEsQ0FBQyxDQUFBO0lBQzNDLENBQUM7SUFFRCxvQkFBb0I7SUFFcEI7Ozs7T0FJRztJQUNILEtBQUssR0FBRyxJQUFJLENBQUMsUUFBUSxDQUFBO0lBRXJCOzs7O09BSUc7SUFDSCxVQUFVLEdBQUcsSUFBSSxDQUFDLGFBQWEsQ0FBQTtJQUUvQjs7OztPQUlHO0lBQ0gsUUFBUSxHQUFHLElBQUksQ0FBQyxXQUFXLENBQUE7SUFFM0I7O09BRUc7SUFDSCxPQUFPLEdBQUcsSUFBSSxDQUFDLFVBQVUsQ0FBQTtJQUV6Qjs7OztPQUlHO0lBQ0gsWUFBWSxHQUFHLElBQUksQ0FBQyxlQUFlLENBQUE7Q0FDdEM7QUE5S0Qsd0NBOEtDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA"}
|
package/lib/components/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./Calendar"), exports);
|
|
18
18
|
__exportStar(require("./CalendarEvent"), exports);
|
|
19
19
|
__exportStar(require("./TimeZone"), exports);
|
|
20
|
-
|
|
20
|
+
__exportStar(require("./TimeZoneOffset"), exports);
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29tcG9uZW50cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsNkNBQTBCO0FBQzFCLGtEQUErQjtBQUMvQiw2Q0FBMEI7QUFDMUIsbURBQWdDIn0=
|
package/lib/date.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { type Property } from './property';
|
|
2
|
+
export declare const ONE_SECOND_MS = 1000;
|
|
3
|
+
export declare const ONE_MINUTE_MS: number;
|
|
4
|
+
export declare const ONE_HOUR_MS: number;
|
|
5
|
+
export declare const ONE_DAY_MS: number;
|
|
6
|
+
export interface CalendarDateOrTime {
|
|
7
|
+
/**
|
|
8
|
+
* Create a property from this date.
|
|
9
|
+
* @param name The name of the property.
|
|
10
|
+
*/
|
|
11
|
+
toProperty(name: string): Property;
|
|
12
|
+
/**
|
|
13
|
+
* Get the string value of this date.
|
|
14
|
+
* @returns An iCalendar date or date-time string.
|
|
15
|
+
*/
|
|
16
|
+
getValue(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Get the date value of this date. For {@link CalendarDate} this is the
|
|
19
|
+
* time at the start of the day.
|
|
20
|
+
* @returns The date value of this date.
|
|
21
|
+
*/
|
|
22
|
+
getDate(): Date;
|
|
23
|
+
/**
|
|
24
|
+
* Check if this date represents a full day, as opposed to a date-time.
|
|
25
|
+
* @returns `true` if this object is a {@link CalendarDate}.
|
|
26
|
+
*/
|
|
27
|
+
isFullDay(): boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Represents a DATE value as defined by RFC5545.
|
|
31
|
+
* This is a date without a time, representing a whole day.
|
|
32
|
+
*/
|
|
33
|
+
export declare class CalendarDate implements CalendarDateOrTime {
|
|
34
|
+
private date;
|
|
35
|
+
constructor(date: Date | string | CalendarDateOrTime);
|
|
36
|
+
toProperty(name: string): Property;
|
|
37
|
+
getValue(): string;
|
|
38
|
+
getDate(): Date;
|
|
39
|
+
isFullDay(): boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare class CalendarDateTime implements CalendarDateOrTime {
|
|
42
|
+
private date;
|
|
43
|
+
constructor(date: Date | string | CalendarDateOrTime);
|
|
44
|
+
toProperty(name: string): Property;
|
|
45
|
+
getValue(): string;
|
|
46
|
+
getDate(): Date;
|
|
47
|
+
isFullDay(): boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Pad a number with leading zeros.
|
|
51
|
+
* @param num The number to pad with zeros.
|
|
52
|
+
* @param length How many digits the resulting string should have.
|
|
53
|
+
* @returns The padded string.
|
|
54
|
+
* @throws If the digits of `num` is greater than `length`.
|
|
55
|
+
* @throws If `num` is NaN, a decimal or negative.
|
|
56
|
+
* @throws If `length` is not NaN, a decimal or less than 1.
|
|
57
|
+
*/
|
|
58
|
+
export declare function padZeros(num: number, length: number): string;
|
|
59
|
+
/**
|
|
60
|
+
* Pad zeros for the year component of a date string.
|
|
61
|
+
* @param year The year, should be positive.
|
|
62
|
+
* @returns The 4-digit padded year.
|
|
63
|
+
*/
|
|
64
|
+
export declare function padYear(year: number): string;
|
|
65
|
+
/**
|
|
66
|
+
* Pad zeros for the month component of a date string.
|
|
67
|
+
* @param month The month, should be between 1 and 12.
|
|
68
|
+
* @returns The 2-digit padded month.
|
|
69
|
+
*/
|
|
70
|
+
export declare function padMonth(month: number): string;
|
|
71
|
+
/**
|
|
72
|
+
* Pad zeros for the day component of a date string.
|
|
73
|
+
* @param day The day, should be between 1 and 31.
|
|
74
|
+
* @returns The 2-digit padded day.
|
|
75
|
+
*/
|
|
76
|
+
export declare function padDay(day: number): string;
|
|
77
|
+
/**
|
|
78
|
+
* Pad zeros for the hours component of a time string.
|
|
79
|
+
* @param hours The hours, should be between 0 and 23.
|
|
80
|
+
* @returns The 2-digit padded hours.
|
|
81
|
+
*/
|
|
82
|
+
export declare function padHours(hours: number): string;
|
|
83
|
+
/**
|
|
84
|
+
* Pad zeros for the minutes component of a time string.
|
|
85
|
+
* @param minutes The minutes, should be between 0 and 59.
|
|
86
|
+
* @returns The 2-digit padded minutes.
|
|
87
|
+
*/
|
|
88
|
+
export declare function padMinutes(minutes: number): string;
|
|
89
|
+
/**
|
|
90
|
+
* Pad zeros for the seconds component of a time string.
|
|
91
|
+
* @param seconds The seconds, should be between 0 and 59.
|
|
92
|
+
* @returns The 2-digit padded seconds.
|
|
93
|
+
*/
|
|
94
|
+
export declare function padSeconds(seconds: number): string;
|
|
95
|
+
/**
|
|
96
|
+
* Parse a date property into a {@link CalendarDateOrTime}.
|
|
97
|
+
* @param dateProperty The property to parse.
|
|
98
|
+
* @param defaultType The default value type to be used if the property does not have an explicit value type.
|
|
99
|
+
* @returns The parsed date as a {@link CalendarDateOrTime}.
|
|
100
|
+
* @throws If the value is invalid for the value type.
|
|
101
|
+
* @throws If the value type is not `DATE-TIME` or `DATE`.
|
|
102
|
+
*/
|
|
103
|
+
export declare function parseDateProperty(dateProperty: Property, defaultType?: 'DATE-TIME' | 'DATE'): CalendarDateOrTime;
|
|
104
|
+
/**
|
|
105
|
+
* Format a date as an iCalendar compatible time string. The day of the date is
|
|
106
|
+
* ignored.
|
|
107
|
+
* @param date The date to convert to a time string.
|
|
108
|
+
* @returns The time of the date formatted according to the iCalendar specification.
|
|
109
|
+
* @throws If the date is invalid.
|
|
110
|
+
*/
|
|
111
|
+
export declare function toTimeString(date: Date): string;
|
|
112
|
+
/**
|
|
113
|
+
* Format a date as an iCalendar compatible date string.
|
|
114
|
+
* @param date The date to convert to a date string.
|
|
115
|
+
* @returns A date string formatted according to the iCalendar specification.
|
|
116
|
+
* @throws If the date is invalid.
|
|
117
|
+
*/
|
|
118
|
+
export declare function toDateString(date: Date): string;
|
|
119
|
+
/**
|
|
120
|
+
* Format a date as an iCalendar compatible date-time string.
|
|
121
|
+
* @param date The date to convert to a date-time string.
|
|
122
|
+
* @returns A date-time string formatted according to the iCalendar specification.
|
|
123
|
+
* @throws If the date is invalid.
|
|
124
|
+
*/
|
|
125
|
+
export declare function toDateTimeString(date: Date): string;
|
|
126
|
+
/**
|
|
127
|
+
* Format a date as an iCalendar compatible date-time string. Offsets the date
|
|
128
|
+
* to UTC using `timeZoneOffset`.
|
|
129
|
+
* @param date The date in local time to convert to UTC and a date-time string.
|
|
130
|
+
* @param timeZoneOffset The timezone offset in minutes.
|
|
131
|
+
* @returns A UTC date-time string formatted according to the iCalendar specification.
|
|
132
|
+
* @throws If the date is invalid.
|
|
133
|
+
* @throws If the offset is invalid.
|
|
134
|
+
* @example
|
|
135
|
+
* // The timezone offset for CET (Central European Time)
|
|
136
|
+
* const timeZoneOffsetCET = -60 // +01:00
|
|
137
|
+
* const date = new Date('2025-08-07T12:00:00') // The time in CET
|
|
138
|
+
* // Returns "20250807T110000Z"
|
|
139
|
+
* const utcDate = toDateTimeStringUTC(date, timeZoneOffsetCET)
|
|
140
|
+
*/
|
|
141
|
+
export declare function toDateTimeStringUTC(date: Date, timeZoneOffset: number): string;
|
|
142
|
+
/**
|
|
143
|
+
* Parse a date-time string to a `Date`.
|
|
144
|
+
* @param dateTime A date-time string formatted according to the iCalendar specification.
|
|
145
|
+
* @returns The parsed date-time.
|
|
146
|
+
* @throws If the date is invalid.
|
|
147
|
+
*/
|
|
148
|
+
export declare function parseDateTimeString(dateTime: string): Date;
|
|
149
|
+
/**
|
|
150
|
+
* Parse a date string to a `Date`.
|
|
151
|
+
* @param date A date-time string formatted according to the iCalendar specification.
|
|
152
|
+
* @returns The parsed date.
|
|
153
|
+
* @throws If the date is invalid.
|
|
154
|
+
*/
|
|
155
|
+
export declare function parseDateString(date: string): Date;
|
|
156
|
+
/**
|
|
157
|
+
* Convert `Date` objects to a {@link CalendarDateOrTime} object or return as
|
|
158
|
+
* is if `date` is already a {@link CalendarDateOrTime}.
|
|
159
|
+
* @param date The date object to convert.
|
|
160
|
+
* @param fullDay If `true`, a `Date` object is converted to {@link CalendarDate}, otherwise `Date` is converted to {@link CalendarDateTime}.
|
|
161
|
+
* @returns A {@link CalendarDateOrTime} as described above.
|
|
162
|
+
*/
|
|
163
|
+
export declare function convertDate<T extends CalendarDateOrTime>(date: Date | T, fullDay?: false): T | CalendarDateTime;
|
|
164
|
+
export declare function convertDate<T extends CalendarDateOrTime>(date: Date | T, fullDay: true): T | CalendarDate;
|
|
165
|
+
//# sourceMappingURL=date.d.ts.map
|