import { DateEnv , DateInput } from '../datelib/env' ; import { DateMarker } from '../datelib/marker' ; import { Action } from './Action' ; import { BaseOptionsRefined } from '../options' ; export function reduceCurrentDate ( currentDate , action ) { switch ( action . type ) { case 'CHANGE_DATE' : return action . dateMarker ; default : return currentDate ; } } export function getInitialDate ( options , dateEnv ) { let initialDateInput = options . initialDate ; if ( initialDateInput != null ) { return dateEnv . createMarker ( initialDateInput ) ; } return getNow ( options . now , dateEnv ) ; } export function getNow ( nowInput , dateEnv ) { if ( typeof nowInput === 'function' ) { nowInput = nowInput ( ) ; } if ( nowInput == null ) { return dateEnv . createNowMarker ( ) ; } return dateEnv . createMarker ( nowInput ) ; }