We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c377ac8 commit fa5c4b6Copy full SHA for fa5c4b6
moment-timezone.js
@@ -144,6 +144,27 @@
144
}
145
146
147
+ function closest(num, arr) {
148
+ if (num < arr[0]) {
149
+ return 0;
150
+ } else if (num >= arr[arr.length-1]) {
151
+ return -1;
152
+ }
153
+
154
+ var mid;
155
+ var lo = 0;
156
+ var hi = arr.length - 1;
157
+ while (hi - lo > 1) {
158
+ mid = Math.floor((lo + hi) / 2);
159
+ if (arr[mid] <= num) {
160
+ lo = mid;
161
+ } else {
162
+ hi = mid;
163
164
165
+ return hi;
166
167
168
Zone.prototype = {
169
_set : function (unpacked) {
170
this.name = unpacked.name;
@@ -158,10 +179,9 @@
179
untils = this.untils,
180
i;
181
- for (i = 0; i < untils.length; i++) {
- if (target < untils[i]) {
- return i;
- }
182
+ i = closest(target,untils);
183
+ if (i >= 0) {
184
+ return i;
185
186
},
187
0 commit comments