rrule-ts 0.2.0 → 0.3.0
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 +24 -0
- package/dist/expand.d.ts.map +1 -1
- package/dist/expand.js +95 -11
- package/dist/expand.js.map +1 -1
- package/dist/locales/de.d.ts +8 -4
- package/dist/locales/de.d.ts.map +1 -1
- package/dist/locales/de.js +126 -26
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/en.d.ts +7 -26
- package/dist/locales/en.d.ts.map +1 -1
- package/dist/locales/en.js +166 -26
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/types.d.ts +113 -0
- package/dist/locales/types.d.ts.map +1 -0
- package/dist/locales/types.js +7 -0
- package/dist/locales/types.js.map +1 -0
- package/dist/text/fromText.d.ts +23 -0
- package/dist/text/fromText.d.ts.map +1 -0
- package/dist/text/fromText.js +604 -0
- package/dist/text/fromText.js.map +1 -0
- package/dist/text/index.d.ts +58 -13
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +56 -16
- package/dist/text/index.js.map +1 -1
- package/dist/text/toText.d.ts +20 -0
- package/dist/text/toText.d.ts.map +1 -0
- package/dist/text/toText.js +230 -0
- package/dist/text/toText.js.map +1 -0
- package/package.json +1 -1
package/dist/locales/en.d.ts
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
/** Locale identifier. */
|
|
4
|
-
id: string;
|
|
5
|
-
/** Weekday names, indexed 0=Monday ... 6=Sunday. */
|
|
6
|
-
weekdays: [string, string, string, string, string, string, string];
|
|
7
|
-
/** Month names, indexed 0=January ... 11=December. */
|
|
8
|
-
months: [
|
|
9
|
-
string,
|
|
10
|
-
string,
|
|
11
|
-
string,
|
|
12
|
-
string,
|
|
13
|
-
string,
|
|
14
|
-
string,
|
|
15
|
-
string,
|
|
16
|
-
string,
|
|
17
|
-
string,
|
|
18
|
-
string,
|
|
19
|
-
string,
|
|
20
|
-
string
|
|
21
|
-
];
|
|
22
|
-
/** Frequency labels. */
|
|
23
|
-
frequencies: Record<string, string>;
|
|
24
|
-
}
|
|
1
|
+
import type { LocalePack } from './types.js';
|
|
2
|
+
export type { LocalePack, LocaleTokens } from './types.js';
|
|
25
3
|
/**
|
|
26
4
|
* English locale pack.
|
|
27
5
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
6
|
+
* formatInterval: n=1 -> 'every day'; n>1 -> 'every N days'.
|
|
7
|
+
* formatOrdinal: 1->'1st', 2->'2nd', 3->'3rd', 4->'4th', -1->'last'.
|
|
8
|
+
* formatCount: 1->'1 time'; N->'N times'.
|
|
9
|
+
* formatList: Oxford comma ('A, B, and C').
|
|
10
|
+
* formatDate: PlainDate -> 'January 1, 2025'; DateTime/Instant -> '...at H:MM'.
|
|
30
11
|
*/
|
|
31
12
|
export declare const en: LocalePack;
|
|
32
13
|
//# sourceMappingURL=en.d.ts.map
|
package/dist/locales/en.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/locales/en.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/locales/en.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5C,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AA6C1D;;;;;;;;GAQG;AACH,eAAO,MAAM,EAAE,EAAE,UAmHhB,CAAA"}
|
package/dist/locales/en.js
CHANGED
|
@@ -1,38 +1,178 @@
|
|
|
1
1
|
// English locale pack for rrule-ts/text (import 'rrule-ts/locales/en').
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// Implements the full LocalePack interface from types.ts with production-quality
|
|
4
|
+
// English strings and formatters.
|
|
5
|
+
import { getTemporal } from '../temporal.js';
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Internal tables (referenced from methods to avoid closure-over-self issues)
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
const EN_MONTHS = [
|
|
10
|
+
'January',
|
|
11
|
+
'February',
|
|
12
|
+
'March',
|
|
13
|
+
'April',
|
|
14
|
+
'May',
|
|
15
|
+
'June',
|
|
16
|
+
'July',
|
|
17
|
+
'August',
|
|
18
|
+
'September',
|
|
19
|
+
'October',
|
|
20
|
+
'November',
|
|
21
|
+
'December',
|
|
22
|
+
];
|
|
23
|
+
const FREQ_SINGULAR = {
|
|
24
|
+
SECONDLY: 'every second',
|
|
25
|
+
MINUTELY: 'every minute',
|
|
26
|
+
HOURLY: 'every hour',
|
|
27
|
+
DAILY: 'every day',
|
|
28
|
+
WEEKLY: 'every week',
|
|
29
|
+
MONTHLY: 'every month',
|
|
30
|
+
YEARLY: 'every year',
|
|
31
|
+
};
|
|
32
|
+
const FREQ_PLURAL = {
|
|
33
|
+
SECONDLY: 'seconds',
|
|
34
|
+
MINUTELY: 'minutes',
|
|
35
|
+
HOURLY: 'hours',
|
|
36
|
+
DAILY: 'days',
|
|
37
|
+
WEEKLY: 'weeks',
|
|
38
|
+
MONTHLY: 'months',
|
|
39
|
+
YEARLY: 'years',
|
|
40
|
+
};
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// English locale pack
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
5
44
|
/**
|
|
6
45
|
* English locale pack.
|
|
7
46
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
47
|
+
* formatInterval: n=1 -> 'every day'; n>1 -> 'every N days'.
|
|
48
|
+
* formatOrdinal: 1->'1st', 2->'2nd', 3->'3rd', 4->'4th', -1->'last'.
|
|
49
|
+
* formatCount: 1->'1 time'; N->'N times'.
|
|
50
|
+
* formatList: Oxford comma ('A, B, and C').
|
|
51
|
+
* formatDate: PlainDate -> 'January 1, 2025'; DateTime/Instant -> '...at H:MM'.
|
|
10
52
|
*/
|
|
11
53
|
export const en = {
|
|
12
54
|
id: 'en',
|
|
13
55
|
weekdays: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
|
|
14
|
-
months:
|
|
15
|
-
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
56
|
+
months: EN_MONTHS,
|
|
57
|
+
tokens: {
|
|
58
|
+
on: 'on',
|
|
59
|
+
at: 'at',
|
|
60
|
+
in: 'in',
|
|
61
|
+
inSingular: 'in',
|
|
62
|
+
until: 'until',
|
|
63
|
+
the: 'the',
|
|
64
|
+
last: 'last',
|
|
65
|
+
lastDay: 'last day',
|
|
66
|
+
weekday: 'weekday',
|
|
67
|
+
},
|
|
68
|
+
formatInterval(n, freq) {
|
|
69
|
+
if (n === 1)
|
|
70
|
+
return FREQ_SINGULAR[freq];
|
|
71
|
+
return `every ${n} ${FREQ_PLURAL[freq]}`;
|
|
72
|
+
},
|
|
73
|
+
formatOrdinal(n) {
|
|
74
|
+
if (n === -1)
|
|
75
|
+
return 'last';
|
|
76
|
+
const abs = Math.abs(n);
|
|
77
|
+
const mod100 = abs % 100;
|
|
78
|
+
const mod10 = abs % 10;
|
|
79
|
+
let suffix;
|
|
80
|
+
if (mod100 >= 11 && mod100 <= 13) {
|
|
81
|
+
// 11th, 12th, 13th: special case
|
|
82
|
+
suffix = 'th';
|
|
83
|
+
}
|
|
84
|
+
else if (mod10 === 1) {
|
|
85
|
+
suffix = 'st';
|
|
86
|
+
}
|
|
87
|
+
else if (mod10 === 2) {
|
|
88
|
+
suffix = 'nd';
|
|
89
|
+
}
|
|
90
|
+
else if (mod10 === 3) {
|
|
91
|
+
suffix = 'rd';
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
suffix = 'th';
|
|
95
|
+
}
|
|
96
|
+
return `${abs}${suffix}`;
|
|
97
|
+
},
|
|
98
|
+
formatCount(n) {
|
|
99
|
+
return n === 1 ? '1 time' : `${n} times`;
|
|
100
|
+
},
|
|
101
|
+
formatList(items) {
|
|
102
|
+
if (items.length === 0)
|
|
103
|
+
return '';
|
|
104
|
+
if (items.length === 1)
|
|
105
|
+
return items[0];
|
|
106
|
+
if (items.length === 2)
|
|
107
|
+
return `${items[0]} and ${items[1]}`;
|
|
108
|
+
// Oxford comma: "A, B, and C"
|
|
109
|
+
return `${items.slice(0, -1).join(', ')}, and ${items[items.length - 1]}`;
|
|
110
|
+
},
|
|
111
|
+
formatDate(date) {
|
|
112
|
+
const T = getTemporal();
|
|
113
|
+
// Use instanceof to safely identify the Temporal variant.
|
|
114
|
+
if (date instanceof T.Instant) {
|
|
115
|
+
const dt = date.toZonedDateTimeISO('UTC');
|
|
116
|
+
const min = String(dt.minute).padStart(2, '0');
|
|
117
|
+
return `${EN_MONTHS[dt.month - 1]} ${dt.day}, ${dt.year} at ${dt.hour}:${min}`;
|
|
118
|
+
}
|
|
119
|
+
if (date instanceof T.PlainDateTime) {
|
|
120
|
+
const min = String(date.minute).padStart(2, '0');
|
|
121
|
+
return `${EN_MONTHS[date.month - 1]} ${date.day}, ${date.year} at ${date.hour}:${min}`;
|
|
122
|
+
}
|
|
123
|
+
// Temporal.PlainDate
|
|
124
|
+
const d = date;
|
|
125
|
+
return `${EN_MONTHS[d.month - 1]} ${d.day}, ${d.year}`;
|
|
126
|
+
},
|
|
127
|
+
formatNthToLastDay(n) {
|
|
128
|
+
// n is the absolute value (n >= 2).
|
|
129
|
+
// EN: '2nd-to-last day', '3rd-to-last day', etc.
|
|
130
|
+
const abs = n;
|
|
131
|
+
const mod100 = abs % 100;
|
|
132
|
+
const mod10 = abs % 10;
|
|
133
|
+
let suffix;
|
|
134
|
+
if (mod100 >= 11 && mod100 <= 13) {
|
|
135
|
+
suffix = 'th';
|
|
136
|
+
}
|
|
137
|
+
else if (mod10 === 1) {
|
|
138
|
+
suffix = 'st';
|
|
139
|
+
}
|
|
140
|
+
else if (mod10 === 2) {
|
|
141
|
+
suffix = 'nd';
|
|
142
|
+
}
|
|
143
|
+
else if (mod10 === 3) {
|
|
144
|
+
suffix = 'rd';
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
suffix = 'th';
|
|
148
|
+
}
|
|
149
|
+
return `${abs}${suffix}-to-last day`;
|
|
150
|
+
},
|
|
151
|
+
formatNthToLastOrdinal(n) {
|
|
152
|
+
// n is the absolute value (n >= 2).
|
|
153
|
+
// Returns the adjectival "Nth-to-last" form used before a weekday name in BYDAY.
|
|
154
|
+
// EN: 2 -> '2nd-to-last', 3 -> '3rd-to-last', 11 -> '11th-to-last', etc.
|
|
155
|
+
const abs = n;
|
|
156
|
+
const mod100 = abs % 100;
|
|
157
|
+
const mod10 = abs % 10;
|
|
158
|
+
let suffix;
|
|
159
|
+
if (mod100 >= 11 && mod100 <= 13) {
|
|
160
|
+
suffix = 'th';
|
|
161
|
+
}
|
|
162
|
+
else if (mod10 === 1) {
|
|
163
|
+
suffix = 'st';
|
|
164
|
+
}
|
|
165
|
+
else if (mod10 === 2) {
|
|
166
|
+
suffix = 'nd';
|
|
167
|
+
}
|
|
168
|
+
else if (mod10 === 3) {
|
|
169
|
+
suffix = 'rd';
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
suffix = 'th';
|
|
173
|
+
}
|
|
174
|
+
return `${abs}${suffix}-to-last`;
|
|
36
175
|
},
|
|
176
|
+
complexRuleFallback: '(complex recurrence rule)',
|
|
37
177
|
};
|
|
38
178
|
//# sourceMappingURL=en.js.map
|
package/dist/locales/en.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.js","sourceRoot":"","sources":["../../src/locales/en.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"en.js","sourceRoot":"","sources":["../../src/locales/en.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,iFAAiF;AACjF,kCAAkC;AAIlC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAI5C,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAE9E,MAAM,SAAS,GAAyB;IACtC,SAAS;IACT,UAAU;IACV,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,MAAM;IACN,QAAQ;IACR,WAAW;IACX,SAAS;IACT,UAAU;IACV,UAAU;CACX,CAAA;AAED,MAAM,aAAa,GAA8B;IAC/C,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,WAAW;IAClB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,MAAM,EAAE,YAAY;CACrB,CAAA;AAED,MAAM,WAAW,GAA8B;IAC7C,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,SAAS;IACnB,MAAM,EAAE,OAAO;IACf,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,QAAQ;IACjB,MAAM,EAAE,OAAO;CAChB,CAAA;AAED,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,EAAE,GAAe;IAC5B,EAAE,EAAE,IAAI;IACR,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC;IACxF,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE;QACN,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI;QACR,UAAU,EAA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AAM,GAAG,IAAI,CAAA;QACf,CAAC;aAAM,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,GAAG,IAAI,CAAA;QACf,CAAC;aAAM,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,GAAG,IAAI,CAAA;QACf,CAAC;aAAM,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,GAAG,IAAI,CAAA;QACf,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,IAAI,CAAA;QACf,CAAC;QACD,OAAO,GAAG,GAAG,GAAG,MAAM,UAAU,CAAA;IAClC,CAAC;IAED,mBAAmB,EAAE,2BAA2B;CACjD,CAAA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { Frequency, RRuleUntil } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Fixed-string connective tokens used to assemble human-readable RRULE clauses.
|
|
4
|
+
* Each token is a locale-specific word or phrase.
|
|
5
|
+
*/
|
|
6
|
+
export interface LocaleTokens {
|
|
7
|
+
/** Precedes a BYDAY or BYMONTHDAY clause. EN: 'on', DE: 'am' */
|
|
8
|
+
on: string;
|
|
9
|
+
/** Precedes a BYHOUR time clause. EN: 'at', DE: 'um' */
|
|
10
|
+
at: string;
|
|
11
|
+
/** Precedes a multi-month BYMONTH clause. EN: 'in', DE: 'in' */
|
|
12
|
+
in: string;
|
|
13
|
+
/** Precedes a single-month BYMONTH clause. EN: 'in', DE: 'im' */
|
|
14
|
+
inSingular: string;
|
|
15
|
+
/** Precedes the UNTIL date. EN: 'until', DE: 'bis' */
|
|
16
|
+
until: string;
|
|
17
|
+
/** Appears between 'on' and an ordinal. EN: 'the', DE: '' (empty, not used in German) */
|
|
18
|
+
the: string;
|
|
19
|
+
/** Used for the -1 ordinal in adjectival BYDAY position. EN: 'last', DE: 'letzten' */
|
|
20
|
+
last: string;
|
|
21
|
+
/** Rendered for BYMONTHDAY=-1. EN: 'last day', DE: 'letzten Tag' */
|
|
22
|
+
lastDay: string;
|
|
23
|
+
/** Used for the BYSETPOS=-1 + Mon-Fri weekday set pattern. EN: 'weekday', DE: 'Werktag' */
|
|
24
|
+
weekday: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A locale pack supplies all human-language strings and formatter functions
|
|
28
|
+
* needed by toText. Consumers pass a LocalePack object directly to toText
|
|
29
|
+
* instead of a locale identifier string, which preserves tree-shaking: only
|
|
30
|
+
* imported locale packs are included in the consumer bundle.
|
|
31
|
+
*
|
|
32
|
+
* The frequencies Record is intentionally absent. All interval phrasing is
|
|
33
|
+
* delegated to formatInterval so that each locale can handle grammatical gender
|
|
34
|
+
* and number agreement (e.g. German jeden/jede/jedes vs alle N).
|
|
35
|
+
*/
|
|
36
|
+
export interface LocalePack {
|
|
37
|
+
/** Locale identifier, e.g. 'en' or 'de'. */
|
|
38
|
+
id: string;
|
|
39
|
+
/**
|
|
40
|
+
* Weekday display names in RFC 5545 order.
|
|
41
|
+
* Index 0 = Monday (MO) through index 6 = Sunday (SU).
|
|
42
|
+
*/
|
|
43
|
+
weekdays: [string, string, string, string, string, string, string];
|
|
44
|
+
/**
|
|
45
|
+
* Month display names.
|
|
46
|
+
* Index 0 = January through index 11 = December.
|
|
47
|
+
*/
|
|
48
|
+
months: [
|
|
49
|
+
string,
|
|
50
|
+
string,
|
|
51
|
+
string,
|
|
52
|
+
string,
|
|
53
|
+
string,
|
|
54
|
+
string,
|
|
55
|
+
string,
|
|
56
|
+
string,
|
|
57
|
+
string,
|
|
58
|
+
string,
|
|
59
|
+
string,
|
|
60
|
+
string
|
|
61
|
+
];
|
|
62
|
+
/** Fixed-string connective tokens for clause assembly. */
|
|
63
|
+
tokens: LocaleTokens;
|
|
64
|
+
/**
|
|
65
|
+
* Render an interval phrase. When n=1 returns singular (e.g. 'every day').
|
|
66
|
+
* When n>1 returns plural with count (e.g. 'every 2 days').
|
|
67
|
+
* Must handle grammatical gender per language.
|
|
68
|
+
*/
|
|
69
|
+
formatInterval(n: number, freq: Frequency): string;
|
|
70
|
+
/**
|
|
71
|
+
* Render an ordinal for a BYDAY or BYSETPOS position.
|
|
72
|
+
* Positive n: 1->'1st' (EN), '1.' (DE).
|
|
73
|
+
* Negative n: -1->'last' (EN adjectival form), 'letzten' (DE).
|
|
74
|
+
*/
|
|
75
|
+
formatOrdinal(n: number): string;
|
|
76
|
+
/**
|
|
77
|
+
* Render a COUNT value as a human phrase.
|
|
78
|
+
* EN: 1->'1 time', 5->'5 times'. DE: '5-mal'.
|
|
79
|
+
*/
|
|
80
|
+
formatCount(n: number): string;
|
|
81
|
+
/**
|
|
82
|
+
* Join a list of strings with locale-appropriate conjunction.
|
|
83
|
+
* EN: Oxford comma ('A, B, and C'). DE: ' und ' with no Oxford comma ('A, B und C').
|
|
84
|
+
*/
|
|
85
|
+
formatList(items: string[]): string;
|
|
86
|
+
/**
|
|
87
|
+
* Render an UNTIL date as a human-readable string.
|
|
88
|
+
* Temporal.PlainDate -> date only (e.g. 'January 1, 2025').
|
|
89
|
+
* Temporal.PlainDateTime or Temporal.Instant -> date + time.
|
|
90
|
+
*/
|
|
91
|
+
formatDate(date: RRuleUntil): string;
|
|
92
|
+
/**
|
|
93
|
+
* Render a "Nth-to-last day" phrase for negative BYMONTHDAY values below -1.
|
|
94
|
+
* n is the absolute value (n >= 2). The phrase must be in the target language.
|
|
95
|
+
* EN: n=2 -> '2nd-to-last day'. DE: n=2 -> 'vorletzten Tag', n=3 -> '3.-letzten Tag'.
|
|
96
|
+
*/
|
|
97
|
+
formatNthToLastDay(n: number): string;
|
|
98
|
+
/**
|
|
99
|
+
* Render just the adjectival "nth-to-last" ordinal for a negative BYDAY ordinal
|
|
100
|
+
* below -1 (e.g. ordinal=-2 for -2MO). n is the absolute value (n >= 2).
|
|
101
|
+
* The returned string is combined with a weekday name by toText.
|
|
102
|
+
* EN: n=2 -> '2nd-to-last'. DE: n=2 -> 'vorletzten', n=3 -> '3.-letzten'.
|
|
103
|
+
*/
|
|
104
|
+
formatNthToLastOrdinal(n: number): string;
|
|
105
|
+
/**
|
|
106
|
+
* The phrase returned by toText when a rule cannot be expressed naturally.
|
|
107
|
+
* Callers who compare against COMPLEX_RULE_FALLBACK should use the EN locale
|
|
108
|
+
* or compare against locale.complexRuleFallback for the locale they use.
|
|
109
|
+
* EN: '(complex recurrence rule)'. DE: '(komplexe Wiederholungsregel)'.
|
|
110
|
+
*/
|
|
111
|
+
complexRuleFallback: string;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/locales/types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,EAAE,EAAE,MAAM,CAAA;IACV,wDAAwD;IACxD,EAAE,EAAE,MAAM,CAAA;IACV,gEAAgE;IAChE,EAAE,EAAE,MAAM,CAAA;IACV,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAA;IAClB,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAA;IACb,yFAAyF;IACzF,GAAG,EAAE,MAAM,CAAA;IACX,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAA;IACZ,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAA;IACf,2FAA2F;IAC3F,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACzB,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAA;IAEV;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAElE;;;OAGG;IACH,MAAM,EAAE;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;KACP,CAAA;IAED,0DAA0D;IAC1D,MAAM,EAAE,YAAY,CAAA;IAEpB;;;;OAIG;IACH,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAAA;IAElD;;;;OAIG;IACH,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAEhC;;;OAGG;IACH,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAE9B;;;OAGG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAEnC;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAA;IAEpC;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAErC;;;;;OAKG;IACH,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAEzC;;;;;OAKG;IACH,mBAAmB,EAAE,MAAM,CAAA;CAC5B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// LocalePack and LocaleTokens interfaces for rrule-ts i18n text rendering.
|
|
2
|
+
//
|
|
3
|
+
// Locale packs are plain objects with static tables and formatter functions.
|
|
4
|
+
// They are imported per-locale (e.g. 'rrule-ts/locales/en') so tree-shaking
|
|
5
|
+
// works: unused locales add zero bytes to the consumer bundle.
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/locales/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,+DAA+D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RRuleOptions } from '../types.js';
|
|
2
|
+
import type { Result } from '../result.js';
|
|
3
|
+
/**
|
|
4
|
+
* Parse a human-readable English recurrence description into RRuleOptions.
|
|
5
|
+
*
|
|
6
|
+
* Only accepts canonical output produced by toText with the EN locale. Not a
|
|
7
|
+
* general natural-language parser.
|
|
8
|
+
*
|
|
9
|
+
* Round-trip guarantee: for all RRuleOptions x where toText(x, {locale: en})
|
|
10
|
+
* does not return the complex-rule fallback string,
|
|
11
|
+
* fromText(toText(x, {locale: en}), {locale: en}).value deep-equals x
|
|
12
|
+
* (excluding dtstart, tzid, wkst, bySecond which are absent from text output,
|
|
13
|
+
* and excluding byMinute=[0] which is indistinguishable from byMinute=undefined
|
|
14
|
+
* in the rendered text).
|
|
15
|
+
*
|
|
16
|
+
* Returns Err if the text cannot be parsed as EN toText output.
|
|
17
|
+
*
|
|
18
|
+
* Out of scope: BYWEEKNO, BYYEARDAY, BYSECOND, WKST,
|
|
19
|
+
* multi-value BYSETPOS, free-form prose not produced by toText.
|
|
20
|
+
* fromText is EN-only: passing DE (or any other locale) text returns Err.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fromText(text: string): Result<RRuleOptions, string>;
|
|
23
|
+
//# sourceMappingURL=fromText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fromText.d.ts","sourceRoot":"","sources":["../../src/text/fromText.ts"],"names":[],"mappings":"AAgEA,OAAO,KAAK,EAAa,YAAY,EAAuB,MAAM,aAAa,CAAA;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAsiB1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAcnE"}
|