@@ -90,12 +90,40 @@ return /******/ (function(modules) { // webpackBootstrap
90
90
// shim for using process in browser
91
91
92
92
var process = module . exports = { } ;
93
+
94
+ // cached from whatever global is present so that test runners that stub it
95
+ // don't break things. But we need to wrap it in a try catch in case it is
96
+ // wrapped in strict mode code which doesn't define any globals. It's inside a
97
+ // function because try/catches deoptimize in certain engines.
98
+
99
+ var cachedSetTimeout ;
100
+ var cachedClearTimeout ;
101
+
102
+ ( function ( ) {
103
+ try {
104
+ cachedSetTimeout = setTimeout ;
105
+ } catch ( e ) {
106
+ cachedSetTimeout = function ( ) {
107
+ throw new Error ( 'setTimeout is not defined' ) ;
108
+ }
109
+ }
110
+ try {
111
+ cachedClearTimeout = clearTimeout ;
112
+ } catch ( e ) {
113
+ cachedClearTimeout = function ( ) {
114
+ throw new Error ( 'clearTimeout is not defined' ) ;
115
+ }
116
+ }
117
+ } ( ) )
93
118
var queue = [ ] ;
94
119
var draining = false ;
95
120
var currentQueue ;
96
121
var queueIndex = - 1 ;
97
122
98
123
function cleanUpNextTick ( ) {
124
+ if ( ! draining || ! currentQueue ) {
125
+ return ;
126
+ }
99
127
draining = false ;
100
128
if ( currentQueue . length ) {
101
129
queue = currentQueue . concat ( queue ) ;
@@ -111,7 +139,7 @@ return /******/ (function(modules) { // webpackBootstrap
111
139
if ( draining ) {
112
140
return ;
113
141
}
114
- var timeout = setTimeout ( cleanUpNextTick ) ;
142
+ var timeout = cachedSetTimeout ( cleanUpNextTick ) ;
115
143
draining = true ;
116
144
117
145
var len = queue . length ;
@@ -128,7 +156,7 @@ return /******/ (function(modules) { // webpackBootstrap
128
156
}
129
157
currentQueue = null ;
130
158
draining = false ;
131
- clearTimeout ( timeout ) ;
159
+ cachedClearTimeout ( timeout ) ;
132
160
}
133
161
134
162
process . nextTick = function ( fun ) {
@@ -140,7 +168,7 @@ return /******/ (function(modules) { // webpackBootstrap
140
168
}
141
169
queue . push ( new Item ( fun , args ) ) ;
142
170
if ( queue . length === 1 && ! draining ) {
143
- setTimeout ( drainQueue , 0 ) ;
171
+ cachedSetTimeout ( drainQueue , 0 ) ;
144
172
}
145
173
} ;
146
174
@@ -1216,7 +1244,7 @@ return /******/ (function(modules) { // webpackBootstrap
1216
1244
this . setState ( {
1217
1245
filteredData : open && filter ? processed : null ,
1218
1246
selectedItem : processed [ idx ] ,
1219
- focusedItem : processed [ ! ~ idx ? 0 : idx ]
1247
+ focusedItem : processed [ ! ~ idx ? 0 : idx ]
1220
1248
} ) ;
1221
1249
} ,
1222
1250
render : function render ( ) {
@@ -4015,7 +4043,7 @@ return /******/ (function(modules) { // webpackBootstrap
4015
4043
4016
4044
return {
4017
4045
selectedItem : items [ idx ] ,
4018
- focusedItem : items [ ! ~ idx ? 0 : idx ] ,
4046
+ focusedItem : items [ ! ~ idx ? 0 : idx ] ,
4019
4047
processedData : items ,
4020
4048
open : false
4021
4049
} ;
@@ -5528,7 +5556,7 @@ return /******/ (function(modules) { // webpackBootstrap
5528
5556
case DAY :
5529
5557
return dates . date ( date , dates . date ( date ) + num )
5530
5558
case WEEK :
5531
- return dates . date ( date , dates . date ( date ) + ( 7 * num ) )
5559
+ return dates . date ( date , dates . date ( date ) + ( 7 * num ) )
5532
5560
case MONTH :
5533
5561
return monthMath ( date , num )
5534
5562
case DECADE :
@@ -5565,18 +5593,19 @@ return /******/ (function(modules) { // webpackBootstrap
5565
5593
date = dates . milliseconds ( date , 0 ) ;
5566
5594
}
5567
5595
5568
- if ( unit === DECADE )
5596
+ if ( unit === DECADE )
5569
5597
date = dates . subtract ( date , dates . year ( date ) % 10 , 'year' )
5570
-
5571
- if ( unit === CENTURY )
5598
+
5599
+ if ( unit === CENTURY )
5572
5600
date = dates . subtract ( date , dates . year ( date ) % 100 , 'year' )
5573
5601
5574
- if ( unit === WEEK )
5602
+ if ( unit === WEEK )
5575
5603
date = dates . weekday ( date , 0 , firstOfWeek ) ;
5576
5604
5577
5605
return date
5578
5606
} ,
5579
5607
5608
+
5580
5609
endOf : function ( date , unit , firstOfWeek ) {
5581
5610
date = new Date ( date )
5582
5611
date = dates . startOf ( date , unit , firstOfWeek )
@@ -5599,7 +5628,7 @@ return /******/ (function(modules) { // webpackBootstrap
5599
5628
max : function ( ) {
5600
5629
return new Date ( Math . max . apply ( Math , arguments ) )
5601
5630
} ,
5602
-
5631
+
5603
5632
inRange : function ( day , min , max , unit ) {
5604
5633
unit = unit || 'day'
5605
5634
@@ -5617,35 +5646,88 @@ return /******/ (function(modules) { // webpackBootstrap
5617
5646
year : createAccessor ( 'FullYear' ) ,
5618
5647
5619
5648
decade : function ( date , val ) {
5620
- return val === undefined
5649
+ return val === undefined
5621
5650
? dates . year ( dates . startOf ( date , DECADE ) )
5622
5651
: dates . add ( date , val + 10 , YEAR ) ;
5623
5652
} ,
5624
5653
5625
5654
century : function ( date , val ) {
5626
- return val === undefined
5655
+ return val === undefined
5627
5656
? dates . year ( dates . startOf ( date , CENTURY ) )
5628
5657
: dates . add ( date , val + 100 , YEAR ) ;
5629
5658
} ,
5630
5659
5631
5660
weekday : function ( date , val , firstDay ) {
5632
5661
var weekday = ( dates . day ( date ) + 7 - ( firstDay || 0 ) ) % 7 ;
5633
5662
5634
- return val === undefined
5635
- ? weekday
5663
+ return val === undefined
5664
+ ? weekday
5636
5665
: dates . add ( date , val - weekday , DAY ) ;
5666
+ } ,
5667
+
5668
+ diff : function ( date1 , date2 , unit , asFloat ) {
5669
+ var dividend , divisor , result ;
5670
+
5671
+ switch ( unit ) {
5672
+ case MILI :
5673
+ case SECONDS :
5674
+ case MINUTES :
5675
+ case HOURS :
5676
+ case DAY :
5677
+ case WEEK :
5678
+ dividend = date2 . getTime ( ) - date1 . getTime ( ) ; break ;
5679
+ case MONTH :
5680
+ case YEAR :
5681
+ case DECADE :
5682
+ case CENTURY :
5683
+ dividend = ( dates . year ( date2 ) - dates . year ( date1 ) ) * 12 + dates . month ( date2 ) - dates . month ( date1 ) ; break ;
5684
+ default :
5685
+ throw new TypeError ( 'Invalid units: "' + unit + '"' ) ;
5686
+ }
5687
+
5688
+ switch ( unit ) {
5689
+ case MILI :
5690
+ divisor = 1 ; break ;
5691
+ case SECONDS :
5692
+ divisor = 1000 ; break ;
5693
+ case MINUTES :
5694
+ divisor = 1000 * 60 ; break ;
5695
+ case HOURS :
5696
+ divisor = 1000 * 60 * 60 ; break ;
5697
+ case DAY :
5698
+ divisor = 1000 * 60 * 60 * 24 ; break ;
5699
+ case WEEK :
5700
+ divisor = 1000 * 60 * 60 * 24 * 7 ; break ;
5701
+ case MONTH :
5702
+ divisor = 1 ; break ;
5703
+ case YEAR :
5704
+ divisor = 12 ; break ;
5705
+ case DECADE :
5706
+ divisor = 120 ; break ;
5707
+ case CENTURY :
5708
+ divisor = 1200 ; break ;
5709
+ default :
5710
+ throw new TypeError ( 'Invalid units: "' + unit + '"' ) ;
5711
+ }
5712
+
5713
+ result = dividend / divisor ;
5714
+
5715
+ return asFloat ? result : absoluteFloor ( result ) ;
5637
5716
}
5638
- }
5717
+ } ;
5639
5718
5719
+ function absoluteFloor ( number ) {
5720
+ return number < 0 ? Math . ceil ( number ) : Math . floor ( number ) ;
5721
+ }
5640
5722
5641
5723
function monthMath ( date , val ) {
5642
5724
var current = dates . month ( date )
5643
5725
, newMonth = ( current + val ) ;
5644
5726
5645
5727
date = dates . month ( date , newMonth )
5646
5728
5647
- if ( newMonth < 0 ) newMonth = 12 + val
5648
-
5729
+ while ( newMonth < 0 ) newMonth = 12 + newMonth
5730
+
5649
5731
//month rollover
5650
5732
if ( dates . month ( date ) !== ( newMonth % 12 ) )
5651
5733
date = dates . date ( date , 0 ) //move to last of month
@@ -5665,8 +5747,8 @@ return /******/ (function(modules) { // webpackBootstrap
5665
5747
}
5666
5748
5667
5749
function createComparer ( operator ) {
5668
- return function ( a , b , unit , maybeFoW ) {
5669
- return operator ( + dates . startOf ( a , unit , maybeFoW ) , + dates . startOf ( b , unit , maybeFoW ) )
5750
+ return function ( a , b , unit ) {
5751
+ return operator ( + dates . startOf ( a , unit ) , + dates . startOf ( b , unit ) )
5670
5752
} ;
5671
5753
}
5672
5754
0 commit comments