@rr0/cms 0.3.38 → 0.3.40
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/CMSGenerator.js +1 -1
- package/dist/DataContentVisitor.js +2 -2
- package/dist/RR0Context.d.ts +1 -1
- package/dist/anchor/CaseAnchorHandler.js +1 -1
- package/dist/book/BookService.test.js +23 -18
- package/dist/lang/LanguageReplaceCommant.test.js +3 -3
- package/dist/lang/RR0Messages.d.ts +2 -33
- package/dist/lang/RR0Messages_en.d.ts +2 -33
- package/dist/lang/RR0Messages_en.js +2 -34
- package/dist/lang/RR0Messages_fr.d.ts +2 -33
- package/dist/lang/RR0Messages_fr.js +2 -34
- package/dist/lang/index.d.ts +1 -0
- package/dist/lang/index.js +1 -0
- package/dist/org/country/CountryMessages.test.js +1 -1
- package/dist/org/country/region/RegionMessages.test.js +3 -3
- package/dist/org/country/region/department/DeparmentMessages.test.js +2 -2
- package/dist/org/country/region/department/city/CityMessages.test.js +4 -4
- package/dist/org/country/region/department/city/CityService.test.js +1 -1
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanDatasource.test.js +1 -1
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanRR0Mapping.js +1 -1
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanTestimonial.d.ts +1 -1
- package/dist/people/PeopleRegexReplaceCommand.test.js +1 -1
- package/dist/people/PeopleReplacer.test.js +2 -2
- package/dist/place/OrganizationPlace.test.js +1 -1
- package/dist/place/PlaceReplacer.test.js +1 -3
- package/dist/place/PlaceService.test.js +2 -2
- package/dist/science/crypto/ufo/enquete/dossier/CaseService.js +1 -1
- package/dist/source/SourceRenderer.d.ts +3 -3
- package/dist/source/SourceRenderer.js +1 -1
- package/dist/test/RR0TestUtil.js +1 -1
- package/dist/time/RR0TimeMessages.d.ts +33 -0
- package/dist/time/RR0TimeMessages.js +1 -0
- package/dist/time/RR0TimeMessages_en.d.ts +34 -0
- package/dist/time/RR0TimeMessages_en.js +38 -0
- package/dist/time/RR0TimeMessages_fr.d.ts +34 -0
- package/dist/time/RR0TimeMessages_fr.js +38 -0
- package/dist/time/TimeContext.d.mts +195 -0
- package/dist/time/TimeContext.mjs +352 -0
- package/dist/time/TimeContext.test.d.mts +1 -0
- package/dist/time/TimeContext.test.mjs +83 -0
- package/dist/time/TimeDirectoryStep.test.js +1 -1
- package/dist/time/TimeService.d.ts +1 -1
- package/dist/time/TimeService.test.js +1 -1
- package/dist/time/TimeTagReplaceCommand.test.js +1 -1
- package/dist/time/TimeUrlBuilder.d.ts +2 -1
- package/dist/time/TimeUrlBuilder.test.js +1 -1
- package/dist/time/datasource/CsvMapper.test.js +7 -7
- package/dist/time/datasource/JsonMapper.test.js +1 -1
- package/dist/time/datasource/acufo/AcufoCase.d.ts +1 -1
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryCsvMapper.js +1 -1
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.test.js +1 -1
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceCsv.test.js +5 -5
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceDatasource.test.js +1 -1
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceTestCases.js +4 -4
- package/dist/time/datasource/fufora/FuforaDatasource.test.js +3 -3
- package/dist/time/datasource/nuforc/NuforcDatasource.test.js +2 -2
- package/dist/time/datasource/nuforc/NuforcRR0Mapper.test.js +2 -2
- package/dist/time/datasource/rr0/RR0Datasource.test.js +1 -1
- package/dist/time/datasource/sceau/SceauDatasource.js +1 -1
- package/dist/time/datasource/sceau/SceauDatasource.test.js +2 -2
- package/dist/time/datasource/ufo-search/UfoSearchDatasource.test.js +2 -2
- package/dist/time/datasource/ufo-search/UfoSearchHttpDatasource.d.ts +1 -1
- package/dist/time/datasource/urecat/UrecatDatasource.test.js +1 -1
- package/dist/time/html/TimeElementFactory.d.ts +1 -1
- package/dist/time/html/TimeElementFactory.js +1 -1
- package/dist/time/html/TimeReplacer.js +1 -1
- package/dist/time/html/TimeReplacer.test.js +12 -12
- package/dist/time/text/TimeTextBuilder.test.js +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RR0TimeMessages } from "../lang/index.js";
|
|
2
|
+
export declare class RR0TimeMessages_en implements RR0TimeMessages {
|
|
3
|
+
duration: {
|
|
4
|
+
days: (d: number) => string;
|
|
5
|
+
hours: (d: number) => string;
|
|
6
|
+
minutes: (mn: number) => string;
|
|
7
|
+
seconds: (s: number) => string;
|
|
8
|
+
lastSeparator: string;
|
|
9
|
+
approximate: (txt: string) => string;
|
|
10
|
+
};
|
|
11
|
+
relative: {
|
|
12
|
+
year: {
|
|
13
|
+
before: string;
|
|
14
|
+
after: string;
|
|
15
|
+
};
|
|
16
|
+
month: {
|
|
17
|
+
before: string;
|
|
18
|
+
after: string;
|
|
19
|
+
later: string;
|
|
20
|
+
};
|
|
21
|
+
day: {
|
|
22
|
+
before: string;
|
|
23
|
+
after: string;
|
|
24
|
+
};
|
|
25
|
+
hour: {
|
|
26
|
+
before: string;
|
|
27
|
+
after: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
on: (approximate: boolean) => string;
|
|
31
|
+
in: (approximate: boolean) => string;
|
|
32
|
+
fromTo: (startReplacement: string, endReplacement: string) => string;
|
|
33
|
+
starting: (approximate: boolean) => string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MessageUtils } from "../lang/index.js";
|
|
2
|
+
export class RR0TimeMessages_en {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.duration = {
|
|
5
|
+
days: (d) => MessageUtils.plural(d, "day"),
|
|
6
|
+
hours: (d) => MessageUtils.plural(d, "hour"),
|
|
7
|
+
minutes: (mn) => MessageUtils.plural(mn, "minute"),
|
|
8
|
+
seconds: (s) => MessageUtils.plural(s, "second"),
|
|
9
|
+
lastSeparator: " and ",
|
|
10
|
+
approximate: (txt) => `${txt} approximately`
|
|
11
|
+
};
|
|
12
|
+
this.relative = {
|
|
13
|
+
year: {
|
|
14
|
+
before: "the year before",
|
|
15
|
+
after: "the year after"
|
|
16
|
+
},
|
|
17
|
+
month: {
|
|
18
|
+
before: "le month before",
|
|
19
|
+
after: "the month after",
|
|
20
|
+
later: "a month later"
|
|
21
|
+
},
|
|
22
|
+
day: {
|
|
23
|
+
before: "the day before",
|
|
24
|
+
after: "the day after"
|
|
25
|
+
},
|
|
26
|
+
hour: {
|
|
27
|
+
before: "one hour before",
|
|
28
|
+
after: "one hour later"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
this.on = (approximate) => {
|
|
32
|
+
return (approximate ? "around " : "on");
|
|
33
|
+
};
|
|
34
|
+
this.in = (approximate) => (approximate ? "around " : "");
|
|
35
|
+
this.fromTo = (startReplacement, endReplacement) => startReplacement + " to " + endReplacement;
|
|
36
|
+
this.starting = (approximate) => "starting " + (approximate ? "" : "the ");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RR0TimeMessages } from "../lang/index.js";
|
|
2
|
+
export declare class RR0TimeMessages_fr implements RR0TimeMessages {
|
|
3
|
+
duration: {
|
|
4
|
+
days: (d: number) => string;
|
|
5
|
+
hours: (d: number) => string;
|
|
6
|
+
minutes: (mn: number) => string;
|
|
7
|
+
seconds: (s: number) => string;
|
|
8
|
+
lastSeparator: string;
|
|
9
|
+
approximate: (txt: string) => string;
|
|
10
|
+
};
|
|
11
|
+
relative: {
|
|
12
|
+
year: {
|
|
13
|
+
before: string;
|
|
14
|
+
after: string;
|
|
15
|
+
};
|
|
16
|
+
month: {
|
|
17
|
+
before: string;
|
|
18
|
+
after: string;
|
|
19
|
+
later: string;
|
|
20
|
+
};
|
|
21
|
+
day: {
|
|
22
|
+
before: string;
|
|
23
|
+
after: string;
|
|
24
|
+
};
|
|
25
|
+
hour: {
|
|
26
|
+
before: string;
|
|
27
|
+
after: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
on: (approximate: boolean) => string;
|
|
31
|
+
in: (approximate: boolean) => string;
|
|
32
|
+
fromTo: (startReplacement: string, endReplacement: string) => string;
|
|
33
|
+
starting: (approximate: boolean) => string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MessageUtils } from "../lang/index.js";
|
|
2
|
+
export class RR0TimeMessages_fr {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.duration = {
|
|
5
|
+
days: (d) => MessageUtils.plural(d, "jour"),
|
|
6
|
+
hours: (d) => MessageUtils.plural(d, "heure"),
|
|
7
|
+
minutes: (mn) => MessageUtils.plural(mn, "minute"),
|
|
8
|
+
seconds: (s) => MessageUtils.plural(s, "seconde"),
|
|
9
|
+
lastSeparator: " et ",
|
|
10
|
+
approximate: (txt) => `environ ${txt}`
|
|
11
|
+
};
|
|
12
|
+
this.relative = {
|
|
13
|
+
year: {
|
|
14
|
+
before: "l'année d'avant",
|
|
15
|
+
after: "l'année suivante"
|
|
16
|
+
},
|
|
17
|
+
month: {
|
|
18
|
+
before: "le mois précédent",
|
|
19
|
+
after: "le mois suivant",
|
|
20
|
+
later: "un mois plus tard"
|
|
21
|
+
},
|
|
22
|
+
day: {
|
|
23
|
+
before: "la veille",
|
|
24
|
+
after: "le lendemain"
|
|
25
|
+
},
|
|
26
|
+
hour: {
|
|
27
|
+
before: "une heure auparavant",
|
|
28
|
+
after: "une heure plus tard"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
this.on = (approximate) => {
|
|
32
|
+
return (approximate ? "vers " : "") + "le ";
|
|
33
|
+
};
|
|
34
|
+
this.in = (approximate) => (approximate ? "vers " : "en ");
|
|
35
|
+
this.fromTo = (startReplacement, endReplacement) => `${startReplacement} à ${endReplacement}`;
|
|
36
|
+
this.starting = (approximate) => "à partir " + (approximate ? "de " : "du ");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time context for a RR0 page.
|
|
3
|
+
*/
|
|
4
|
+
export class TimeContext {
|
|
5
|
+
/**
|
|
6
|
+
* @readonly
|
|
7
|
+
*/
|
|
8
|
+
static readonly MINUTE: 60;
|
|
9
|
+
/**
|
|
10
|
+
* @readonly
|
|
11
|
+
*/
|
|
12
|
+
static readonly HOUR: number;
|
|
13
|
+
/**
|
|
14
|
+
* @readonly
|
|
15
|
+
*/
|
|
16
|
+
static readonly DAY: number;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {string} timeStr
|
|
20
|
+
* @return {TimeContext}
|
|
21
|
+
*/
|
|
22
|
+
static fromString(timeStr: string): TimeContext;
|
|
23
|
+
/**
|
|
24
|
+
* @param {Date} date
|
|
25
|
+
* @return {TimeContext}
|
|
26
|
+
*/
|
|
27
|
+
static fromDate(date: Date): TimeContext;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param {number} [_year]
|
|
31
|
+
* @param {number} [_month]
|
|
32
|
+
* @param {number} [_dayOfMonth]
|
|
33
|
+
* @param {number} [_hour]
|
|
34
|
+
* @param {number} [_minutes]
|
|
35
|
+
* @param {string} [_timeZone]
|
|
36
|
+
* @param {boolean} [approximate]
|
|
37
|
+
* @param {boolean} [approximateTime]
|
|
38
|
+
* @param {TimeContext | undefined} [from]
|
|
39
|
+
* @param {TimeContext | undefined} [to]
|
|
40
|
+
* @param {number | undefined} [duration]
|
|
41
|
+
*/
|
|
42
|
+
constructor(_year?: number, _month?: number, _dayOfMonth?: number, _hour?: number, _minutes?: number, _timeZone?: string, approximate?: boolean, approximateTime?: boolean, from?: TimeContext | undefined, to?: TimeContext | undefined, duration?: number | undefined);
|
|
43
|
+
/**
|
|
44
|
+
* @type EdtfDate | undefined
|
|
45
|
+
*/
|
|
46
|
+
date: EdtfDate | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* @type EdtfInterval | undefined
|
|
49
|
+
*/
|
|
50
|
+
interval: EdtfInterval | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* @type EdtfDuration | undefined
|
|
53
|
+
*/
|
|
54
|
+
duration: EdtfDuration | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* @type RR0TimeMessages
|
|
57
|
+
*/
|
|
58
|
+
messages: RR0TimeMessages;
|
|
59
|
+
/**
|
|
60
|
+
* @return {EdtfDate | undefined}
|
|
61
|
+
*/
|
|
62
|
+
get from(): EdtfDate | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* @return {EdtfDate | undefined}
|
|
65
|
+
*/
|
|
66
|
+
get to(): EdtfDate | undefined;
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @param {boolean} approx
|
|
70
|
+
*/
|
|
71
|
+
set approximate(approx: boolean);
|
|
72
|
+
/**
|
|
73
|
+
* @return {boolean}
|
|
74
|
+
*/
|
|
75
|
+
get approximate(): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* @return {boolean}
|
|
78
|
+
*/
|
|
79
|
+
get approximateTime(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* @param {string} timeStr
|
|
82
|
+
* @return If the string could be parsed
|
|
83
|
+
*/
|
|
84
|
+
updateFromStr(timeStr: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @return {number | undefined}
|
|
88
|
+
*/
|
|
89
|
+
getYear(): number | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* @param {number | undefined} year
|
|
92
|
+
* @param {boolean} [print]
|
|
93
|
+
* @return {TimeContext}
|
|
94
|
+
*/
|
|
95
|
+
setYear(year: number | undefined, print?: boolean): TimeContext;
|
|
96
|
+
/**
|
|
97
|
+
* @return {number | undefined}
|
|
98
|
+
*/
|
|
99
|
+
getMonth(): number | undefined;
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param {number | undefined} month
|
|
103
|
+
* @param {boolean} [print]
|
|
104
|
+
* @return {TimeContext}
|
|
105
|
+
*/
|
|
106
|
+
setMonth(month: number | undefined, print?: boolean): TimeContext;
|
|
107
|
+
/**
|
|
108
|
+
* @return {number | undefined}
|
|
109
|
+
*/
|
|
110
|
+
getDayOfMonth(): number | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* @param {number | undefined} dayOfMonth
|
|
113
|
+
* @param {boolean} [print]
|
|
114
|
+
* @return {TimeContext}
|
|
115
|
+
*/
|
|
116
|
+
setDayOfMonth(dayOfMonth: number | undefined, print?: boolean): TimeContext;
|
|
117
|
+
/**
|
|
118
|
+
* @return {number | undefined}
|
|
119
|
+
*/
|
|
120
|
+
getHour(): number | undefined;
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
* @param {number | undefined} hour
|
|
124
|
+
* @param {boolean} [print]
|
|
125
|
+
* @return {TimeContext}
|
|
126
|
+
*/
|
|
127
|
+
setHour(hour: number | undefined, print?: boolean): TimeContext;
|
|
128
|
+
/**
|
|
129
|
+
* @return {number | undefined}
|
|
130
|
+
*/
|
|
131
|
+
getMinutes(): number | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* @param {number | undefined} minutes
|
|
134
|
+
* @return {TimeContext}
|
|
135
|
+
*/
|
|
136
|
+
setMinutes(minutes: number | undefined): TimeContext;
|
|
137
|
+
/**
|
|
138
|
+
* @deprecated
|
|
139
|
+
* @return {string | undefined}
|
|
140
|
+
*/
|
|
141
|
+
getTimeZone(): string | undefined;
|
|
142
|
+
/**
|
|
143
|
+
* @return {string | undefined}
|
|
144
|
+
*/
|
|
145
|
+
getTimeshift(): string | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* @param {string | undefined} timeZone
|
|
148
|
+
* @return {TimeContext}
|
|
149
|
+
*/
|
|
150
|
+
setTimeZone(timeZone: string | undefined): TimeContext;
|
|
151
|
+
/**
|
|
152
|
+
* @return {boolean}
|
|
153
|
+
*/
|
|
154
|
+
isDefined(): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* @return {TimeContext}
|
|
157
|
+
*/
|
|
158
|
+
clone(): TimeContext;
|
|
159
|
+
/**
|
|
160
|
+
*
|
|
161
|
+
* @return {this}
|
|
162
|
+
*/
|
|
163
|
+
reset(): this;
|
|
164
|
+
/**
|
|
165
|
+
* @param {TimeContext} other
|
|
166
|
+
* @return {boolean}
|
|
167
|
+
*/
|
|
168
|
+
isBefore(other: TimeContext): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* @param {TimeContext} other
|
|
171
|
+
* @return {boolean}
|
|
172
|
+
*/
|
|
173
|
+
isAfter(other: TimeContext): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* @param {TimeContext} other
|
|
176
|
+
* @return {boolean}
|
|
177
|
+
*/
|
|
178
|
+
equals(other: TimeContext): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* @return {string}
|
|
181
|
+
*/
|
|
182
|
+
toString(): string;
|
|
183
|
+
/**
|
|
184
|
+
* @return {string}
|
|
185
|
+
*/
|
|
186
|
+
toJSON(): string;
|
|
187
|
+
/**
|
|
188
|
+
* @protected
|
|
189
|
+
* @param {any} value
|
|
190
|
+
*/
|
|
191
|
+
protected isSet(value: any): boolean;
|
|
192
|
+
}
|
|
193
|
+
import { Level2Date as EdtfDate } from "@rr0/time";
|
|
194
|
+
import { Level2Interval as EdtfInterval } from "@rr0/time";
|
|
195
|
+
import { Level2Duration as EdtfDuration } from "@rr0/time";
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { Level2Date as EdtfDate, Level2Duration as EdtfDuration, Level2Interval as EdtfInterval, Level2Timeshift } from "@rr0/time";
|
|
2
|
+
/**
|
|
3
|
+
* Time context for a RR0 page.
|
|
4
|
+
*/
|
|
5
|
+
export class TimeContext {
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {number} [_year]
|
|
9
|
+
* @param {number} [_month]
|
|
10
|
+
* @param {number} [_dayOfMonth]
|
|
11
|
+
* @param {number} [_hour]
|
|
12
|
+
* @param {number} [_minutes]
|
|
13
|
+
* @param {string} [_timeZone]
|
|
14
|
+
* @param {boolean} [approximate]
|
|
15
|
+
* @param {boolean} [approximateTime]
|
|
16
|
+
* @param {TimeContext | undefined} [from]
|
|
17
|
+
* @param {TimeContext | undefined} [to]
|
|
18
|
+
* @param {number | undefined} [duration]
|
|
19
|
+
*/
|
|
20
|
+
constructor(_year = undefined, _month = undefined, _dayOfMonth = undefined, _hour = undefined, _minutes = undefined, _timeZone = undefined, approximate = false, approximateTime = false,
|
|
21
|
+
/** @deprecated */
|
|
22
|
+
from = undefined,
|
|
23
|
+
/** @deprecated */
|
|
24
|
+
to = undefined, duration = undefined) {
|
|
25
|
+
if (from) {
|
|
26
|
+
this.interval = new EdtfInterval(from === null || from === void 0 ? void 0 : from.date, to === null || to === void 0 ? void 0 : to.date);
|
|
27
|
+
}
|
|
28
|
+
else if (duration) {
|
|
29
|
+
this.duration = new EdtfDuration(duration);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.date = new EdtfDate({ year: _year, month: _month, day: _dayOfMonth, hour: _hour, minute: _minutes, timeZone: _timeZone });
|
|
33
|
+
if (approximate) {
|
|
34
|
+
this.date.year.approximate = true;
|
|
35
|
+
}
|
|
36
|
+
if (approximateTime) {
|
|
37
|
+
if (this.date.hour) {
|
|
38
|
+
this.date.hour.approximateComponent = true;
|
|
39
|
+
}
|
|
40
|
+
if (this.date.minutes) {
|
|
41
|
+
this.date.minutes.approximateComponent = true;
|
|
42
|
+
}
|
|
43
|
+
if (this.date.seconds) {
|
|
44
|
+
this.date.seconds.approximateComponent = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @return {EdtfDate | undefined}
|
|
51
|
+
*/
|
|
52
|
+
get from() {
|
|
53
|
+
var _a;
|
|
54
|
+
return (_a = this.interval) === null || _a === void 0 ? void 0 : _a.start;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @return {EdtfDate | undefined}
|
|
58
|
+
*/
|
|
59
|
+
get to() {
|
|
60
|
+
var _a;
|
|
61
|
+
return (_a = this.interval) === null || _a === void 0 ? void 0 : _a.end;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @return {boolean}
|
|
65
|
+
*/
|
|
66
|
+
get approximate() {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
return ((_a = this.date) === null || _a === void 0 ? void 0 : _a.approximate) || ((_b = this.interval) === null || _b === void 0 ? void 0 : _b.approximate) || ((_c = this.duration) === null || _c === void 0 ? void 0 : _c.approximate);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @param {boolean} approx
|
|
73
|
+
*/
|
|
74
|
+
set approximate(approx) {
|
|
75
|
+
this.date.approximate = approx;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @return {boolean}
|
|
79
|
+
*/
|
|
80
|
+
get approximateTime() {
|
|
81
|
+
var _a, _b, _c, _d, _e, _f;
|
|
82
|
+
return this.approximate || ((_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.hour) === null || _b === void 0 ? void 0 : _b.approximate) || ((_d = (_c = this.date) === null || _c === void 0 ? void 0 : _c.minute) === null || _d === void 0 ? void 0 : _d.approximate) || ((_f = (_e = this.date) === null || _e === void 0 ? void 0 : _e.second) === null || _f === void 0 ? void 0 : _f.approximate);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* @param {string} timeStr
|
|
87
|
+
* @return {TimeContext}
|
|
88
|
+
*/
|
|
89
|
+
static fromString(timeStr) {
|
|
90
|
+
const timeContext = new TimeContext();
|
|
91
|
+
timeContext.updateFromStr(timeStr);
|
|
92
|
+
return timeContext;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @param {Date} date
|
|
96
|
+
* @return {TimeContext}
|
|
97
|
+
*/
|
|
98
|
+
static fromDate(date) {
|
|
99
|
+
return new TimeContext(date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), "UTC" + (date.getTimezoneOffset() < 0 ? "-" : "+") + date.getTimezoneOffset());
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @param {string} timeStr
|
|
103
|
+
* @return If the string could be parsed
|
|
104
|
+
*/
|
|
105
|
+
updateFromStr(timeStr) {
|
|
106
|
+
let valid = Boolean(timeStr);
|
|
107
|
+
if (valid) {
|
|
108
|
+
try {
|
|
109
|
+
this.interval = EdtfInterval.fromString(timeStr);
|
|
110
|
+
this.date = undefined;
|
|
111
|
+
this.duration = undefined;
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
try {
|
|
115
|
+
this.duration = EdtfDuration.fromString(timeStr);
|
|
116
|
+
this.interval = undefined;
|
|
117
|
+
this.date = undefined;
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
try {
|
|
121
|
+
this.date = EdtfDate.fromString(timeStr);
|
|
122
|
+
this.duration = undefined;
|
|
123
|
+
this.interval = undefined;
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
console.warn("Could not resolve time string", timeStr, e.message);
|
|
127
|
+
valid = false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return valid;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
*
|
|
136
|
+
* @return {number | undefined}
|
|
137
|
+
*/
|
|
138
|
+
getYear() {
|
|
139
|
+
var _a, _b;
|
|
140
|
+
return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.year) === null || _b === void 0 ? void 0 : _b.value;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @param {number | undefined} year
|
|
144
|
+
* @param {boolean} [print]
|
|
145
|
+
* @return {TimeContext}
|
|
146
|
+
*/
|
|
147
|
+
setYear(year, print = true) {
|
|
148
|
+
var _a, _b;
|
|
149
|
+
if (year !== ((_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.year) === null || _b === void 0 ? void 0 : _b.value) && print) {
|
|
150
|
+
this.setMonth(undefined, print);
|
|
151
|
+
}
|
|
152
|
+
this.date = this.date || new EdtfDate();
|
|
153
|
+
this.date.year = year;
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* @return {number | undefined}
|
|
158
|
+
*/
|
|
159
|
+
getMonth() {
|
|
160
|
+
var _a, _b;
|
|
161
|
+
return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.month) === null || _b === void 0 ? void 0 : _b.value;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* @param {number | undefined} month
|
|
166
|
+
* @param {boolean} [print]
|
|
167
|
+
* @return {TimeContext}
|
|
168
|
+
*/
|
|
169
|
+
setMonth(month, print = true) {
|
|
170
|
+
var _a, _b;
|
|
171
|
+
if (month !== ((_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.month) === null || _b === void 0 ? void 0 : _b.value) && print) {
|
|
172
|
+
this.setDayOfMonth(undefined, print);
|
|
173
|
+
}
|
|
174
|
+
this.date = this.date || new EdtfDate();
|
|
175
|
+
this.date.month = month;
|
|
176
|
+
return this;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* @return {number | undefined}
|
|
180
|
+
*/
|
|
181
|
+
getDayOfMonth() {
|
|
182
|
+
var _a, _b;
|
|
183
|
+
return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.day) === null || _b === void 0 ? void 0 : _b.value;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* @param {number | undefined} dayOfMonth
|
|
187
|
+
* @param {boolean} [print]
|
|
188
|
+
* @return {TimeContext}
|
|
189
|
+
*/
|
|
190
|
+
setDayOfMonth(dayOfMonth, print = true) {
|
|
191
|
+
var _a, _b;
|
|
192
|
+
if (dayOfMonth !== ((_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.day) === null || _b === void 0 ? void 0 : _b.value) && print) {
|
|
193
|
+
this.setHour(undefined, print);
|
|
194
|
+
}
|
|
195
|
+
this.date = this.date || new EdtfDate();
|
|
196
|
+
this.date.day = dayOfMonth;
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* @return {number | undefined}
|
|
201
|
+
*/
|
|
202
|
+
getHour() {
|
|
203
|
+
var _a, _b;
|
|
204
|
+
return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.hour) === null || _b === void 0 ? void 0 : _b.value;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
*
|
|
208
|
+
* @param {number | undefined} hour
|
|
209
|
+
* @param {boolean} [print]
|
|
210
|
+
* @return {TimeContext}
|
|
211
|
+
*/
|
|
212
|
+
setHour(hour, print = true) {
|
|
213
|
+
var _a, _b;
|
|
214
|
+
if (hour !== ((_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.hour) === null || _b === void 0 ? void 0 : _b.value) && print) {
|
|
215
|
+
this.setMinutes(undefined);
|
|
216
|
+
}
|
|
217
|
+
this.date = this.date || new EdtfDate();
|
|
218
|
+
this.date.hour = hour;
|
|
219
|
+
return this;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* @return {number | undefined}
|
|
223
|
+
*/
|
|
224
|
+
getMinutes() {
|
|
225
|
+
var _a, _b;
|
|
226
|
+
return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.minute) === null || _b === void 0 ? void 0 : _b.value;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* @param {number | undefined} minutes
|
|
230
|
+
* @return {TimeContext}
|
|
231
|
+
*/
|
|
232
|
+
setMinutes(minutes) {
|
|
233
|
+
this.date = this.date || new EdtfDate();
|
|
234
|
+
this.date.minute = minutes;
|
|
235
|
+
return this;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* @deprecated
|
|
239
|
+
* @return {string | undefined}
|
|
240
|
+
*/
|
|
241
|
+
getTimeZone() {
|
|
242
|
+
var _a, _b;
|
|
243
|
+
return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.timeshift) === null || _b === void 0 ? void 0 : _b.toString();
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @return {string | undefined}
|
|
247
|
+
*/
|
|
248
|
+
getTimeshift() {
|
|
249
|
+
var _a, _b;
|
|
250
|
+
return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.timeshift) === null || _b === void 0 ? void 0 : _b.toString();
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* @param {string | undefined} timeZone
|
|
254
|
+
* @return {TimeContext}
|
|
255
|
+
*/
|
|
256
|
+
setTimeZone(timeZone) {
|
|
257
|
+
this.date = this.date || new Level2Timeshift();
|
|
258
|
+
try {
|
|
259
|
+
this.date.timeshift = Level2Timeshift.fromString(timeZone);
|
|
260
|
+
}
|
|
261
|
+
catch (e) {
|
|
262
|
+
console.warn("Could not resolve time zone", timeZone, e.message);
|
|
263
|
+
}
|
|
264
|
+
return this;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* @return {boolean}
|
|
268
|
+
*/
|
|
269
|
+
isDefined() {
|
|
270
|
+
var _a, _b, _c, _d, _e;
|
|
271
|
+
const date = this.date;
|
|
272
|
+
if (!date) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
return ((_a = date.year) === null || _a === void 0 ? void 0 : _a.value) !== undefined
|
|
276
|
+
|| ((_b = date.month) === null || _b === void 0 ? void 0 : _b.value) !== undefined
|
|
277
|
+
|| ((_c = date.day) === null || _c === void 0 ? void 0 : _c.value) !== undefined
|
|
278
|
+
|| ((_d = date.hour) === null || _d === void 0 ? void 0 : _d.value) !== undefined
|
|
279
|
+
|| ((_e = date.minute) === null || _e === void 0 ? void 0 : _e.value) !== undefined;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* @return {TimeContext}
|
|
283
|
+
*/
|
|
284
|
+
clone() {
|
|
285
|
+
var _a, _b, _c, _d, _e, _f;
|
|
286
|
+
const date = this.date;
|
|
287
|
+
const interval = this.interval;
|
|
288
|
+
return new TimeContext((_a = date === null || date === void 0 ? void 0 : date.year) === null || _a === void 0 ? void 0 : _a.value, (_b = date === null || date === void 0 ? void 0 : date.month) === null || _b === void 0 ? void 0 : _b.value, (_c = date === null || date === void 0 ? void 0 : date.day) === null || _c === void 0 ? void 0 : _c.value, (_d = date === null || date === void 0 ? void 0 : date.hour) === null || _d === void 0 ? void 0 : _d.value, (_e = date === null || date === void 0 ? void 0 : date.minute) === null || _e === void 0 ? void 0 : _e.value, (_f = date === null || date === void 0 ? void 0 : date.timeshift) === null || _f === void 0 ? void 0 : _f.value, this.approximate, this.approximateTime, interval === null || interval === void 0 ? void 0 : interval.from, interval === null || interval === void 0 ? void 0 : interval.to, this.duration);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
*
|
|
292
|
+
* @return {this}
|
|
293
|
+
*/
|
|
294
|
+
reset() {
|
|
295
|
+
this.date = undefined;
|
|
296
|
+
this.interval = undefined;
|
|
297
|
+
this.duration = undefined;
|
|
298
|
+
return this;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* @param {TimeContext} other
|
|
302
|
+
* @return {boolean}
|
|
303
|
+
*/
|
|
304
|
+
isBefore(other) {
|
|
305
|
+
return this.toString().localeCompare(other.toString()) < 0;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* @param {TimeContext} other
|
|
309
|
+
* @return {boolean}
|
|
310
|
+
*/
|
|
311
|
+
isAfter(other) {
|
|
312
|
+
return this.toString().localeCompare(other.toString()) > 0;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* @param {TimeContext} other
|
|
316
|
+
* @return {boolean}
|
|
317
|
+
*/
|
|
318
|
+
equals(other) {
|
|
319
|
+
return this.toString() === other.toString();
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* @return {string}
|
|
323
|
+
*/
|
|
324
|
+
toString() {
|
|
325
|
+
return this.date ? this.date.toString() : "";
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* @return {string}
|
|
329
|
+
*/
|
|
330
|
+
toJSON() {
|
|
331
|
+
return this.toString();
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* @protected
|
|
335
|
+
* @param {any} value
|
|
336
|
+
*/
|
|
337
|
+
isSet(value) {
|
|
338
|
+
return value !== void 0 && value != null;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* @readonly
|
|
343
|
+
*/
|
|
344
|
+
TimeContext.MINUTE = 60;
|
|
345
|
+
/**
|
|
346
|
+
* @readonly
|
|
347
|
+
*/
|
|
348
|
+
TimeContext.HOUR = 60 * TimeContext.MINUTE;
|
|
349
|
+
/**
|
|
350
|
+
* @readonly
|
|
351
|
+
*/
|
|
352
|
+
TimeContext.DAY = 24 * TimeContext.HOUR;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|