| 
									
										
										
										
											2016-01-19 21:11:20 -05:00
										 |  |  | import moment from 'moment-timezone'; | 
					
						
							| 
									
										
										
										
											2015-12-10 14:52:09 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // day count between two epochs (inclusive)
 | 
					
						
							| 
									
										
										
										
											2016-01-19 21:11:20 -05:00
										 |  |  | export function dayCount([head, tail], timezone = 'UTC') { | 
					
						
							| 
									
										
										
										
											2015-12-10 14:52:09 -08:00
										 |  |  |   return Math.ceil( | 
					
						
							| 
									
										
										
										
											2019-02-18 19:32:49 +00:00
										 |  |  |     moment( | 
					
						
							|  |  |  |       moment(head) | 
					
						
							|  |  |  |         .tz(timezone) | 
					
						
							|  |  |  |         .endOf('day') | 
					
						
							|  |  |  |     ).diff( | 
					
						
							|  |  |  |       moment(tail) | 
					
						
							|  |  |  |         .tz(timezone) | 
					
						
							|  |  |  |         .startOf('day'), | 
					
						
							| 
									
										
										
										
											2016-01-03 05:39:47 +01:00
										 |  |  |       'days', | 
					
						
							| 
									
										
										
										
											2019-02-18 19:32:49 +00:00
										 |  |  |       true | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2019-02-06 14:19:58 +00:00
										 |  |  |   ); | 
					
						
							| 
									
										
										
										
											2015-12-10 14:52:09 -08:00
										 |  |  | } |