Skip to content

Commit 17cfe5f

Browse files
authored
fix(dtstart): align field names with method names (#566)
1 parent 27bb1e5 commit 17cfe5f

15 files changed

+72
-75
lines changed

e2e/commonjs.e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('Commonjs', () => {
2121
});
2222
const set = new RRuleSet(
2323
new DtStart({
24-
datetime: DateTime.create(1997, 6, 10, 9, 0, 0, false),
24+
value: DateTime.create(1997, 6, 10, 9, 0, 0, false),
2525
tzid: 'US/Eastern',
2626
}),
2727
).addRRule(rrule);

e2e/esm.e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('ESM', () => {
2323
});
2424
const set = new RRuleSet(
2525
new DtStart({
26-
datetime: DateTime.create(1997, 6, 10, 9, 0, 0, false),
26+
value: DateTime.create(1997, 6, 10, 9, 0, 0, false),
2727
tzid: 'US/Eastern',
2828
}),
2929
).addRRule(rrule);

e2e/wasm.e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('WASM', () => {
2323
});
2424
const set = new RRuleSet(
2525
new DtStart({
26-
datetime: DateTime.create(1997, 6, 10, 9, 0, 0, false),
26+
value: DateTime.create(1997, 6, 10, 9, 0, 0, false),
2727
tzid: 'US/Eastern',
2828
}),
2929
).addRRule(rrule);

src/dtstart.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import {
88
export interface DtStartOptions<
99
DT extends DateTime<Time> | DateTime<undefined>,
1010
> {
11-
datetime: DT;
11+
value: DT;
1212
tzid?: string;
1313
}
1414

1515
export interface DtStartLike<DT extends DateTimeLike | DateLike> {
16-
datetime: DT;
16+
value: DT;
1717
tzid?: string;
1818
}
1919

@@ -23,17 +23,14 @@ export class DtStart<
2323
public readonly value: DT;
2424
public readonly tzid?: string;
2525

26-
public constructor(datetime: DT, tzid?: string);
26+
public constructor(value: DT, tzid?: string);
2727
public constructor(options: DtStartOptions<DT>);
28-
public constructor(
29-
datetimeOrOptions: DT | DtStartOptions<DT>,
30-
tzid?: string,
31-
) {
32-
if ('datetime' in datetimeOrOptions) {
33-
this.value = datetimeOrOptions.datetime;
34-
this.tzid = datetimeOrOptions.tzid;
28+
public constructor(valueOrOptions: DT | DtStartOptions<DT>, tzid?: string) {
29+
if ('value' in valueOrOptions) {
30+
this.value = valueOrOptions.value;
31+
this.tzid = valueOrOptions.tzid;
3532
} else {
36-
this.value = datetimeOrOptions;
33+
this.value = valueOrOptions;
3734
this.tzid = tzid;
3835
}
3936
}
@@ -48,7 +45,7 @@ export class DtStart<
4845
plain: DtStartLike<DateTimeLike> | DtStartLike<DateLike>,
4946
): DtStart<DateTime<Time>> | DtStart<DateTime<undefined>> {
5047
return new this({
51-
datetime: DateTime.fromPlain(plain.datetime),
48+
value: DateTime.fromPlain(plain.value),
5249
tzid: plain.tzid,
5350
});
5451
}
@@ -69,7 +66,7 @@ export class DtStart<
6966
: DateLike,
7067
>(): DtStartLike<DTL> {
7168
return {
72-
datetime: this.value.toPlain() as DTL,
69+
value: this.value.toPlain() as DTL,
7370
tzid: this.tzid,
7471
};
7572
}

src/rrule-set.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class RRuleSet<DT extends DateTime<Time> | DateTime<undefined>>
9393
): RRuleSet<DT> {
9494
const set = new RRuleSet<DT>({
9595
dtstart: new DtStart<DT>({
96-
datetime: DateTime.fromNumeric<DT>(rust.dtstart),
96+
value: DateTime.fromNumeric<DT>(rust.dtstart),
9797
tzid: rust.tzid ?? undefined,
9898
}),
9999
rrules: rust.rrules.map((rrule) => RRule.fromRust<DT>(rrule)),

tests/dtstart.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('DtStart', () => {
7676
datetime: DateTime.utc(2024, 1, 1, 12, 0, 0),
7777
tzid: 'America/New_York',
7878
expected: {
79-
datetime: {
79+
value: {
8080
year: 2024,
8181
month: 1,
8282
day: 1,
@@ -91,7 +91,7 @@ describe('DtStart', () => {
9191
{
9292
datetime: DateTime.date(2024, 1, 1),
9393
expected: {
94-
datetime: {
94+
value: {
9595
year: 2024,
9696
month: 1,
9797
day: 1,
@@ -116,7 +116,7 @@ describe('DtStart', () => {
116116
'America/New_York',
117117
),
118118
plain: {
119-
datetime: {
119+
value: {
120120
year: 2024,
121121
month: 1,
122122
day: 1,
@@ -131,7 +131,7 @@ describe('DtStart', () => {
131131
{
132132
dtstart: new DtStart(DateTime.date(2024, 1, 1)),
133133
plain: {
134-
datetime: {
134+
value: {
135135
year: 2024,
136136
month: 1,
137137
day: 1,

tests/recurrence/daily.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('Daily', () => {
1313
it('daily for 10 occurrences (date-only)', () => {
1414
const set = new RRuleSet(
1515
new DtStart({
16-
datetime: DateTime.date(1997, 9, 2),
16+
value: DateTime.date(1997, 9, 2),
1717
tzid: 'US/Eastern',
1818
}),
1919
).addRRule(new RRule<DateTime<undefined>>(Frequency.Daily).setCount(10));
@@ -43,7 +43,7 @@ describe('Daily', () => {
4343
const rrule = new RRule(Frequency.Daily).setCount(10);
4444
const set = new RRuleSet(
4545
new DtStart({
46-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
46+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
4747
tzid: 'US/Eastern',
4848
}),
4949
).addRRule(rrule);
@@ -73,7 +73,7 @@ describe('Daily', () => {
7373
const rrule = new RRule(Frequency.Daily).setCount(10);
7474
const set = new RRuleSet(
7575
new DtStart({
76-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
76+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
7777
tzid: 'US/Eastern',
7878
}),
7979
).addRRule(rrule);
@@ -99,7 +99,7 @@ describe('Daily', () => {
9999
const rrule = new RRule(Frequency.Daily).setCount(10);
100100
const set = new RRuleSet(
101101
new DtStart({
102-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
102+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
103103
tzid: 'US/Eastern',
104104
}),
105105
).addRRule(rrule);
@@ -123,7 +123,7 @@ describe('Daily', () => {
123123
);
124124
const set = new RRuleSet(
125125
new DtStart({
126-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
126+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
127127
tzid: 'US/Eastern',
128128
}),
129129
).addRRule(rrule);
@@ -148,7 +148,7 @@ describe('Daily', () => {
148148
const rrule = new RRule(Frequency.Daily).setCount(6).setInterval(2);
149149
const set = new RRuleSet(
150150
new DtStart({
151-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
151+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
152152
tzid: 'US/Eastern',
153153
}),
154154
).addRRule(rrule);
@@ -174,7 +174,7 @@ describe('Daily', () => {
174174
const rrule = new RRule(Frequency.Daily).setCount(5).setInterval(10);
175175
const set = new RRuleSet(
176176
new DtStart({
177-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
177+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
178178
tzid: 'US/Eastern',
179179
}),
180180
).addRRule(rrule);
@@ -202,7 +202,7 @@ describe('Daily', () => {
202202
.setUntil(DateTime.create(2000, 1, 31, 14, 0, 0, false));
203203
const set = new RRuleSet(
204204
new DtStart({
205-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
205+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
206206
tzid: 'US/Eastern',
207207
}),
208208
).addRRule(rrule);
@@ -239,7 +239,7 @@ describe('Daily', () => {
239239

240240
const set = new RRuleSet(
241241
new DtStart({
242-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
242+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
243243
tzid: 'Asia/Tbilisi',
244244
}),
245245
)

tests/recurrence/hourly.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('Hourly', () => {
55
const rrule = new RRule(Frequency.Hourly).setCount(5);
66
const set = new RRuleSet(
77
new DtStart({
8-
datetime: DateTime.create(2024, 6, 8, 4, 0, 0, false),
8+
value: DateTime.create(2024, 6, 8, 4, 0, 0, false),
99
tzid: 'America/Cancun',
1010
}),
1111
).addRRule(rrule);
@@ -30,7 +30,7 @@ describe('Hourly', () => {
3030
const rrule = new RRule(Frequency.Hourly).setCount(6).setByHour([5, 8]);
3131
const set = new RRuleSet(
3232
new DtStart({
33-
datetime: DateTime.create(2024, 6, 8, 4, 0, 0, false),
33+
value: DateTime.create(2024, 6, 8, 4, 0, 0, false),
3434
tzid: 'America/Cancun',
3535
}),
3636
).addRRule(rrule);
@@ -56,7 +56,7 @@ describe('Hourly', () => {
5656
const rrule = new RRule(Frequency.Hourly).setCount(4).setBySecond([9, 10]);
5757
const set = new RRuleSet(
5858
new DtStart({
59-
datetime: DateTime.create(2024, 6, 8, 4, 0, 0, false),
59+
value: DateTime.create(2024, 6, 8, 4, 0, 0, false),
6060
tzid: 'America/Cancun',
6161
}),
6262
).addRRule(rrule);

tests/recurrence/minutely.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('Minutely', () => {
55
const rrule = new RRule(Frequency.Minutely).setCount(5);
66
const set = new RRuleSet(
77
new DtStart({
8-
datetime: DateTime.create(2024, 6, 8, 4, 0, 0, false),
8+
value: DateTime.create(2024, 6, 8, 4, 0, 0, false),
99
tzid: 'America/Cancun',
1010
}),
1111
).addRRule(rrule);

tests/recurrence/monthly.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Monthly', () => {
1717
.setBySetpos([1]);
1818
const set = new RRuleSet(
1919
new DtStart({
20-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
20+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
2121
tzid: 'US/Eastern',
2222
}),
2323
).addRRule(rrule);
@@ -50,7 +50,7 @@ describe('Monthly', () => {
5050
.setBySetpos([1]);
5151
const set = new RRuleSet(
5252
new DtStart({
53-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
53+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
5454
tzid: 'US/Eastern',
5555
}),
5656
).addRRule(rrule);
@@ -78,7 +78,7 @@ describe('Monthly', () => {
7878
.setBySetpos([1, -1]);
7979
const set = new RRuleSet(
8080
new DtStart({
81-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
81+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
8282
tzid: 'US/Eastern',
8383
}),
8484
).addRRule(rrule);
@@ -111,7 +111,7 @@ describe('Monthly', () => {
111111
.setByMonthday([13]);
112112
const set = new RRuleSet(
113113
new DtStart({
114-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
114+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
115115
tzid: 'America/New_York',
116116
}),
117117
)
@@ -146,7 +146,7 @@ describe('Monthly', () => {
146146
.setBySetpos([-2]);
147147
const set = new RRuleSet(
148148
new DtStart({
149-
datetime: DateTime.create(1997, 9, 29, 9, 0, 0, false),
149+
value: DateTime.create(1997, 9, 29, 9, 0, 0, false),
150150
tzid: 'America/New_York',
151151
}),
152152
).addRRule(rrule);
@@ -176,7 +176,7 @@ describe('Monthly', () => {
176176
.setBySetpos([-2]);
177177
const set = new RRuleSet(
178178
new DtStart({
179-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
179+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
180180
tzid: 'US/Eastern',
181181
}),
182182
).addRRule(rrule);
@@ -202,7 +202,7 @@ describe('Monthly', () => {
202202
const rrule = new RRule(Frequency.Monthly).setByMonthday([-3]);
203203
const set = new RRuleSet(
204204
new DtStart({
205-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
205+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
206206
tzid: 'US/Eastern',
207207
}),
208208
).addRRule(rrule);
@@ -229,7 +229,7 @@ describe('Monthly', () => {
229229
.setByMonthday([2, 15]);
230230
const set = new RRuleSet(
231231
new DtStart({
232-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
232+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
233233
tzid: 'US/Eastern',
234234
}),
235235
).addRRule(rrule);
@@ -261,7 +261,7 @@ describe('Monthly', () => {
261261
.setByMonthday([1, -1]);
262262
const set = new RRuleSet(
263263
new DtStart({
264-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
264+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
265265
tzid: 'US/Eastern',
266266
}),
267267
).addRRule(rrule);
@@ -294,7 +294,7 @@ describe('Monthly', () => {
294294
.setByMonthday([10, 11, 12, 13, 14, 15]);
295295
const set = new RRuleSet(
296296
new DtStart({
297-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
297+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
298298
tzid: 'US/Eastern',
299299
}),
300300
).addRRule(rrule);
@@ -324,7 +324,7 @@ describe('Monthly', () => {
324324
const rrule = new RRule(Frequency.Monthly).setCount(5);
325325
const set = new RRuleSet(
326326
new DtStart({
327-
datetime: DateTime.create(2012, 2, 1, 2, 30, 0, false),
327+
value: DateTime.create(2012, 2, 1, 2, 30, 0, false),
328328
tzid: 'UTC',
329329
}),
330330
)
@@ -360,7 +360,7 @@ describe('Monthly', () => {
360360
.setByWeekday([Weekday.Tuesday]);
361361
const set = new RRuleSet(
362362
new DtStart({
363-
datetime: DateTime.create(1997, 9, 2, 9, 0, 0, false),
363+
value: DateTime.create(1997, 9, 2, 9, 0, 0, false),
364364
tzid: 'US/Eastern',
365365
}),
366366
).addRRule(rrule);
@@ -399,7 +399,7 @@ describe('Monthly', () => {
399399
.setCount(6);
400400
const set = new RRuleSet(
401401
new DtStart({
402-
datetime: DateTime.create(1997, 9, 22, 9, 0, 0, false),
402+
value: DateTime.create(1997, 9, 22, 9, 0, 0, false),
403403
tzid: 'US/Eastern',
404404
}),
405405
).addRRule(rrule);

0 commit comments

Comments
 (0)