import getTimezoneOffsetInMilliseconds from '../_lib/getTimezoneOffsetInMilliseconds/index' ; import startOfDay from '../startOfDay/index' ; import requiredArgs from '../_lib/requiredArgs/index' ; const MILLISECONDS_IN_DAY = 86400000 ; name category summary description param { Date | Number } dateLeft param { Date | Number } dateRight returns { Number } throws example export default function differenceInCalendarDays ( dirtyDateLeft , dirtyDateRight ) { requiredArgs ( 2 , arguments ) ; const startOfDayLeft = startOfDay ( dirtyDateLeft ) ; const startOfDayRight = startOfDay ( dirtyDateRight ) ; const timestampLeft = startOfDayLeft . getTime ( ) - getTimezoneOffsetInMilliseconds ( startOfDayLeft ) ; const timestampRight = startOfDayRight . getTime ( ) - getTimezoneOffsetInMilliseconds ( startOfDayRight ) ; return Math . round ( ( timestampLeft - timestampRight ) / MILLISECONDS_IN_DAY ) ; }