File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments