import { Duration , unitOfTime } from 'moment-timezone' ; example export const getHighestTimeUnit = ( duration ) : unitOfTime . Base => { if ( duration . asYears ( ) >= 1 ) { return 'year' ; } if ( duration . asMonths ( ) >= 1 ) { return 'month' ; } if ( duration . asWeeks ( ) >= 1 ) { return 'week' ; } if ( duration . asDays ( ) >= 1 ) { return 'day' ; } if ( duration . asHours ( ) >= 1 ) { return 'hour' ; } if ( duration . asMinutes ( ) >= 1 ) { return 'minute' ; } if ( duration . asSeconds ( ) >= 1 ) { return 'second' ; } return 'millisecond' ; } ; /**
 * Returns true if the given duration is valid to be used with by the  TimeIntervalTriggeringPolicy *
 * See  TimeIntervalTriggeringPolicyConfig . interval for rules and reasons around this validation.
  export const isValidRolloverInterval = ( duration ) : boolean => { const highestUnit = getHighestTimeUnit ( duration ) ; const asHighestUnit = duration . as ( highestUnit ) ; return Number . isInteger ( asHighestUnit ) ; } ;