Skip to content

Commit 5288c41

Browse files
committed
Fix and tests for get offset during a transition
1 parent 6d7afce commit 5288c41

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/MomentZoneRules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class MomentZoneRules extends ZoneRules{
8787
offsetOfLocalDateTime(localDateTime){
8888
const info = this._offsetInfo(localDateTime);
8989
if (info instanceof ZoneOffsetTransition) {
90-
return info.getOffsetBefore();
90+
return info.offsetBefore();
9191
}
9292
return info;
9393
}

test/MomentZoneRulesTest.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ describe('MomentZoneRules', () => {
8282
assertEquals(europeParis.offset(createLocalDateTime(2008, 10, 1, 0, 0)), OFFSET_PTWO);
8383
assertEquals(europeParis.offset(createLocalDateTime(2008, 11, 1, 0, 0)), OFFSET_PONE);
8484
assertEquals(europeParis.offset(createLocalDateTime(2800, 1, 1, 0, 0)), OFFSET_PONE);
85+
86+
// gap
87+
assertEquals(europeParis.offset(createLocalDateTime(2016, 3, 27, 2, 0)), OFFSET_PONE);
88+
assertEquals(europeParis.offset(createLocalDateTime(2016, 3, 27, 2, 30)), OFFSET_PONE);
89+
assertEquals(europeParis.offset(createLocalDateTime(2016, 3, 27, 3, 0)), OFFSET_PTWO);
90+
91+
// overlap
92+
assertEquals(europeParis.offset(createLocalDateTime(2016, 10, 30, 2, 0)), OFFSET_PTWO);
93+
assertEquals(europeParis.offset(createLocalDateTime(2016, 10, 30, 2, 30)), OFFSET_PTWO);
94+
assertEquals(europeParis.offset(createLocalDateTime(2016, 10, 30, 3, 0)), OFFSET_PONE);
8595
});
8696

8797
it('Europe/London', () => {

0 commit comments

Comments
 (0)