Skip to content

Commit d122df2

Browse files
author
Sander Hoogendoorn
committed
fix: added inAmsterdam, inLondon, inNewYork to DateTime
1 parent 49a901a commit d122df2

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

packages/easy/src/domain/DateTime.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ export class DateTime extends Value<Optional<string>> {
118118
return new DateTime(this.luxon.setZone(zone) as any);
119119
}
120120

121+
inAmsterdam(): DateTime {
122+
return this.withZone('Europe/Amsterdam');
123+
}
124+
125+
inNewYork(): DateTime {
126+
return this.withZone('America/New_York');
127+
}
128+
129+
inLondon(): DateTime {
130+
return this.withZone('Europe/London');
131+
}
132+
121133
toString(): string {
122134
return this.value ?? '';
123135
}

packages/easy/test/domain/DateTime.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,19 @@ describe('DateTime', () => {
444444
const result = start.withClock(clock);
445445
expect(result).toMatchText('2021-02-06T03:03:01.000Z');
446446
});
447+
448+
test('inAmsterdam', () => {
449+
const d = new DateTime(iso).inAmsterdam();
450+
expect(d).toMatchText('2021-03-25T09:39:44.000+01:00');
451+
});
452+
453+
test('inNewYork', () => {
454+
const d = new DateTime(iso).inNewYork();
455+
expect(d).toMatchText(new_york);
456+
});
457+
458+
test('inLondon', () => {
459+
const d = new DateTime(iso).inLondon();
460+
expect(d).toMatchText('2021-03-25T08:39:44.000+00:00');
461+
});
447462
});

0 commit comments

Comments
 (0)