Skip to content

Commit bf37bbd

Browse files
committed
Fix transition boundaries, binary search return index on match
1 parent 4f76f41 commit bf37bbd

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

src/MomentZoneRules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class LDTUntils {
425425
function ldtBinarySearch(array, value) {
426426
let hi = array.size - 1, lo = -1, mid;
427427
while (hi - lo > 1) {
428-
if (value.isAfter(array.get(mid = hi + lo >> 1))) {
428+
if (!value.isBefore(array.get(mid = hi + lo >> 1))) {
429429
lo = mid;
430430
} else {
431431
hi = mid;

test/MomentZoneRulesTest.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ describe('MomentZoneRules', () => {
172172

173173
const testLocalToZoneEquality = [
174174
['2016-03-27T01:59', EUROPE_BERLIN, '2016-03-27T01:59+01:00[Europe/Berlin]'],
175-
// ['2016-03-27T02:00', EUROPE_BERLIN, '2016-03-27T03:00+02:00[Europe/Berlin]'],
175+
['2016-03-27T02:00', EUROPE_BERLIN, '2016-03-27T03:00+02:00[Europe/Berlin]'],
176176
['2016-03-27T02:30', EUROPE_BERLIN, '2016-03-27T03:30+02:00[Europe/Berlin]'],
177-
// ['2016-03-27T03:00', EUROPE_BERLIN, '2016-03-27T03:00+02:00[Europe/Berlin]']
177+
['2016-03-27T03:00', EUROPE_BERLIN, '2016-03-27T03:00+02:00[Europe/Berlin]'],
178178
['2016-03-27T03:01', EUROPE_BERLIN, '2016-03-27T03:01+02:00[Europe/Berlin]'],
179179
['2016-03-13T01:59', AMERICA_NEW_YORCK, '2016-03-13T01:59-05:00[America/New_York]'],
180-
// ['2016-03-13T02:00', AMERICA_NEW_YORCK, '2016-03-13T03:00-04:00[America/New_York]'],
180+
['2016-03-13T02:00', AMERICA_NEW_YORCK, '2016-03-13T03:00-04:00[America/New_York]'],
181181
['2016-03-13T02:30', AMERICA_NEW_YORCK, '2016-03-13T03:30-04:00[America/New_York]'],
182-
// ['2016-03-13T03:00', AMERICA_NEW_YORCK, '2016-03-13T03:00-04:00[America/New_York]'],
182+
['2016-03-13T03:00', AMERICA_NEW_YORCK, '2016-03-13T03:00-04:00[America/New_York]'],
183183
['2016-03-13T03:01', AMERICA_NEW_YORCK, '2016-03-13T03:01-04:00[America/New_York]'],
184184
];
185185

@@ -196,14 +196,14 @@ describe('MomentZoneRules', () => {
196196
const testLocalToZoneEquality = () => {
197197
return [
198198
['2016-10-30T01:59', EUROPE_BERLIN, '2016-10-30T01:59+02:00[Europe/Berlin]'],
199-
// ['2016-10-30T02:00', EUROPE_BERLIN, '2016-10-30T02:00+02:00[Europe/Berlin]'],
199+
['2016-10-30T02:00', EUROPE_BERLIN, '2016-10-30T02:00+02:00[Europe/Berlin]'],
200200
['2016-10-30T02:30', EUROPE_BERLIN, '2016-10-30T02:30+02:00[Europe/Berlin]'],
201-
// ['2016-10-30T03:00', EUROPE_BERLIN, '2016-10-30T03:00+01:00[Europe/Berlin]'],
201+
['2016-10-30T03:00', EUROPE_BERLIN, '2016-10-30T03:00+01:00[Europe/Berlin]'],
202202
['2016-10-30T03:01', EUROPE_BERLIN, '2016-10-30T03:01+01:00[Europe/Berlin]'],
203203
['2016-11-06T00:59', AMERICA_NEW_YORCK, '2016-11-06T00:59-04:00[America/New_York]'],
204-
// ['2016-11-06T01:00', AMERICA_NEW_YORCK, '2016-11-06T01:00-04:00[America/New_York]'],
204+
['2016-11-06T01:00', AMERICA_NEW_YORCK, '2016-11-06T01:00-04:00[America/New_York]'],
205205
['2016-11-06T01:30', AMERICA_NEW_YORCK, '2016-11-06T01:30-04:00[America/New_York]'],
206-
// ['2016-11-06T02:00', AMERICA_NEW_YORCK, '2016-11-06T02:00-05:00[America/New_York]'],
206+
['2016-11-06T02:00', AMERICA_NEW_YORCK, '2016-11-06T02:00-05:00[America/New_York]'],
207207
['2016-11-06T02:01', AMERICA_NEW_YORCK, '2016-11-06T02:01-05:00[America/New_York]'],
208208
];
209209
};

test/reference/LocalDateTest.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ describe('org.threeten.bp.TestLocalDate', () => {
1717

1818
describe('atStartOfDay()', () => {
1919

20-
// TODO fixme
21-
it.skip('test_atStartOfDay_dstGap', () => {
20+
it('test_atStartOfDay_dstGap', () => {
2221
const t = LocalDate.of(2007, 4, 1);
2322
assertEquals(t.atStartOfDay(ZONE_GAZA),
2423
ZonedDateTime.of(LocalDateTime.of(2007, 4, 1, 1, 0), ZONE_GAZA));

test/reference/LocalDateTimeTest.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ describe('org.threeten.bp.TestLocalDateTime', () => {
4949
assertEquals(t.atZone(OFFSET_PTWO), ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), OFFSET_PTWO));
5050
});
5151

52-
// TODO Fixme
53-
it.skip('test_atZone_dstGap', () => {
52+
it('test_atZone_dstGap', () => {
5453
const t = LocalDateTime.of(2007, 4, 1, 0, 0);
5554
assertEquals(t.atZone(ZONE_GAZA),
5655
ZonedDateTime.of(LocalDateTime.of(2007, 4, 1, 1, 0), ZONE_GAZA));

0 commit comments

Comments
 (0)