MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / DateToDay

Function DateToDay

Conversions/DateDayDifference.js:12–22  ·  view source on GitHub ↗
(dd, mm, yyyy)

Source from the content-addressed store, hash-verified

10import { parseDate } from '../Timing-Functions/ParseDate'
11
12const DateToDay = (dd, mm, yyyy) => {
13 return (
14 365 * (yyyy - 1) +
15 Math.floor((yyyy - 1) / 4) -
16 Math.floor((yyyy - 1) / 100) +
17 Math.floor((yyyy - 1) / 400) +
18 dd +
19 Math.floor((367 * mm - 362) / 12) +
20 (mm <= 2 ? 0 : isLeapYear(yyyy) ? -1 : -2)
21 )
22}
23
24const DateDayDifference = (date1, date2) => {
25 const firstDate = parseDate(date1)

Callers 1

DateDayDifferenceFunction · 0.70

Calls 1

isLeapYearFunction · 0.90

Tested by

no test coverage detected