ronantakizawa/codereview-bench huggingface dataset:
Repository: date-fns/date-fns
File: src/nextDay/index.ts (TypeScript)

Code before:
/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of Week?
 *
 * @description
 * When is the next day of week?
 * {0|1|2|3|4|5|6} the day of week, 0 represents Sunday
 *
 * @param {Date} date - the date to check
 * @param {number} day - day of week
 * @returns {Date} the date is the next day of week
 * @throws {TypeError} 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 22, 2020?
 * const result = nextMonday(new Date(2020, 2, 22), 1)
 * => new Date(2020, 2, 23)
 *
 * @example
 * When is the next Tuesday after Mar, 22, 2020?
 * const result = nextMonday(new Date(2020, 2, 22), 2)
 * => new Date(2020, 2, 24)
 **/

export default function nextDay(date: Date, day: number): Date {
  requiredArgs(2, arguments)
  // Throw an exception `Invalid Day` if the day is out or range
  if (!baseMap.includes(day + 1)) {
    throw new RangeError('Invalid Day')
  }

  const map = genMap(day)
  return addDays(date, map[getDay(date)])
}

function genMap(daysToMove: number): number[] {
  if (daysToMove === 0) {
    return baseMap
  } else {
    const mapStart = baseMap.slice(-daysToMove)
    const mapEnd = baseMap.slice(0, baseMap.length - daysToMove)
    return mapStart.concat(mapEnd)
  }
}


Review comment (suggestion):
```suggestion
export default function nextDay(date: Date | number, day: number): Date {
```

Code after:
const baseMap = [7, 6, 5, 4, 3, 2, 1]

/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of the week?
 *
 * @description
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
 *
 * @param {Date | number} date - the date to check
 * @param {Day} day - day of the week
 * @returns {Date} - the date is the next day of week
 * @throws {TypeError} - 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 20, 2020?
 * const result = nextDay(new Date(2020, 2, 20), 1)
 * => Mon Mar 23 2020 00:00:00
 *
 * @example
 * When is the next Tuesday after Mar, 21, 2020?
 * const result = nextDay(new Date(2020, 2, 21), 2)
 * => Tue Mar 24 2020 00:00:00
 **/

export default function nextDay(date: Date | number, day: Day): Date {
  requiredArgs(2, arguments)
  const map = genMap(day)
  return addDays(toDate(date), map[getDay(toDate(date))])
}

function genMap(daysToMove: number): number[] {
  if (daysToMove === 0) {
    return baseMap
  } else {
    const mapStart = baseMap.slice(-daysToMove)
    const mapEnd = baseMap.slice(0, baseMap.length - daysToMove)
    return mapStart.concat(mapEnd)
  }
}
Repository: date-fns/date-fns
File: src/nextDay/index.ts (TypeScript)

Code before:
import requiredArgs from '../_lib/requiredArgs/index'
import getDay from '../getDay'
import addDays from '../addDays'

const baseMap = [7, 6, 5, 4, 3, 2, 1]

/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of Week?
 *
 * @description
 * When is the next day of week?
 * {0|1|2|3|4|5|6} the day of week, 0 represents Sunday
 *
 * @param {Date} date - the date to check
 * @param {number} day - day of week
 * @returns {Date} the date is the next day of week
 * @throws {TypeError} 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 22, 2020?
 * const result = nextMonday(new Date(2020, 2, 22), 1)
 * => new Date(2020, 2, 23)
 *
 * @example
 * When is the next Tuesday after Mar, 22, 2020?
 * const result = nextMonday(new Date(2020, 2, 22), 2)
 * => new Date(2020, 2, 24)
 **/

export default function nextDay(date: Date, day: number): Date {
  requiredArgs(2, arguments)
  // Throw an exception `Invalid Day` if the day is out or range
  if (!baseMap.includes(day + 1)) {
    throw new RangeError('Invalid Day')
  }

  const map = genMap(day)
  return addDays(date, map[getDay(date)])
}

Review comment (suggestion):
```suggestion
 * @param {Date | number} date - the date to check
```

Code after:
import requiredArgs from '../_lib/requiredArgs/index'
import getDay from '../getDay'
import addDays from '../addDays'
import toDate from '../toDate'
import { Day } from '../types'

const baseMap = [7, 6, 5, 4, 3, 2, 1]

/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of the week?
 *
 * @description
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
 *
 * @param {Date | number} date - the date to check
 * @param {Day} day - day of the week
 * @returns {Date} - the date is the next day of week
 * @throws {TypeError} - 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 20, 2020?
 * const result = nextDay(new Date(2020, 2, 20), 1)
 * => Mon Mar 23 2020 00:00:00
 *
 * @example
 * When is the next Tuesday after Mar, 21, 2020?
 * const result = nextDay(new Date(2020, 2, 21), 2)
 * => Tue Mar 24 2020 00:00:00
 **/

export default function nextDay(date: Date | number, day: Day): Date {
  requiredArgs(2, arguments)
  const map = genMap(day)
  return addDays(toDate(date), map[getDay(toDate(date))])
}

function genMap(daysToMove: number): number[] {
  if (daysToMove === 0) {
    return baseMap
Repository: date-fns/date-fns
File: src/nextDay/index.ts (TypeScript)

Code before:
import requiredArgs from '../_lib/requiredArgs/index'
import getDay from '../getDay'
import addDays from '../addDays'

const baseMap = [7, 6, 5, 4, 3, 2, 1]

/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of Week?
 *
 * @description
 * When is the next day of week?
 * {0|1|2|3|4|5|6} the day of week, 0 represents Sunday
 *
 * @param {Date} date - the date to check
 * @param {number} day - day of week
 * @returns {Date} the date is the next day of week
 * @throws {TypeError} 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 22, 2020?
 * const result = nextMonday(new Date(2020, 2, 22), 1)
 * => new Date(2020, 2, 23)
 *
 * @example
 * When is the next Tuesday after Mar, 22, 2020?
 * const result = nextMonday(new Date(2020, 2, 22), 2)
 * => new Date(2020, 2, 24)
 **/

export default function nextDay(date: Date, day: number): Date {
  requiredArgs(2, arguments)
  // Throw an exception `Invalid Day` if the day is out or range
  if (!baseMap.includes(day + 1)) {
    throw new RangeError('Invalid Day')
  }

  const map = genMap(day)

Review comment (suggestion):
```suggestion
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
```

Code after:
import requiredArgs from '../_lib/requiredArgs/index'
import getDay from '../getDay'
import addDays from '../addDays'
import toDate from '../toDate'
import { Day } from '../types'

const baseMap = [7, 6, 5, 4, 3, 2, 1]

/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of the week?
 *
 * @description
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
 *
 * @param {Date | number} date - the date to check
 * @param {Day} day - day of the week
 * @returns {Date} - the date is the next day of week
 * @throws {TypeError} - 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 20, 2020?
 * const result = nextDay(new Date(2020, 2, 20), 1)
 * => Mon Mar 23 2020 00:00:00
 *
 * @example
 * When is the next Tuesday after Mar, 21, 2020?
 * const result = nextDay(new Date(2020, 2, 21), 2)
 * => Tue Mar 24 2020 00:00:00
 **/

export default function nextDay(date: Date | number, day: Day): Date {
  requiredArgs(2, arguments)
  const map = genMap(day)
  return addDays(toDate(date), map[getDay(toDate(date))])
}

function genMap(daysToMove: number): number[] {
Repository: date-fns/date-fns
File: src/nextDay/index.ts (TypeScript)

Code before:

/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of Week?
 *
 * @description
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
 *
 * @param {Date | number} date - the date to check
 * @param {number} day - day of week
 * @returns {Date} the date is the next day of week
 * @throws {TypeError} 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 20, 2020?
 * const result = nextDay(new Date(2020, 2, 20), 1)
 * => new Date(2020, 2, 23)
 *
 * @example
 * When is the next Tuesday after Mar, 21, 2020?
 * const result = nextDay(new Date(2020, 2, 21), 2)
 * => new Date(2020, 2, 24)
 **/

export default function nextDay(date: Date | number, day: number): Date {
  requiredArgs(2, arguments)
  // Throw an exception `Invalid Day` if the day is out or range
  if (!baseMap.includes(day + 1)) {
    throw new RangeError('Invalid Day')
  }

  if (!isValid(date)) {
    throw new RangeError('Invalid Date')
  }

  const map = genMap(day)
  return addDays(toDate(date), map[getDay(toDate(date))])
}

function genMap(daysToMove: number): number[] {
  if (daysToMove === 0) {
    return baseMap
  } else {
    const mapStart = baseMap.slice(-daysToMove)
    const mapEnd = baseMap.slice(0, baseMap.length - daysToMove)
    return mapStart.concat(mapEnd)
  }
}


Review comment (suggestion):
Let's instead of checking the type in runtime and throwing `throw new RangeError('Invalid Day')` use an alias for day: 
```suggestion
export default function nextDay(date: Date | number, day: Day): Date {
```

...and add to `types.ts`:

```ts
export type Day = 0 | 1 | 2 | 3 | 4 | 5 | 6
``` 

Code after:

/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of the week?
 *
 * @description
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
 *
 * @param {Date | number} date - the date to check
 * @param {Day} day - day of the week
 * @returns {Date} - the date is the next day of week
 * @throws {TypeError} - 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 20, 2020?
 * const result = nextDay(new Date(2020, 2, 20), 1)
 * => Mon Mar 23 2020 00:00:00
 *
 * @example
 * When is the next Tuesday after Mar, 21, 2020?
 * const result = nextDay(new Date(2020, 2, 21), 2)
 * => Tue Mar 24 2020 00:00:00
 **/

export default function nextDay(date: Date | number, day: Day): Date {
  requiredArgs(2, arguments)
  const map = genMap(day)
  return addDays(toDate(date), map[getDay(toDate(date))])
}

function genMap(daysToMove: number): number[] {
  if (daysToMove === 0) {
    return baseMap
  } else {
    const mapStart = baseMap.slice(-daysToMove)
    const mapEnd = baseMap.slice(0, baseMap.length - daysToMove)
    return mapStart.concat(mapEnd)
  }
}
Repository: date-fns/date-fns
File: src/nextDay/index.ts (TypeScript)

Code before:
 *
 * @description
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
 *
 * @param {Date | number} date - the date to check
 * @param {number} day - day of week
 * @returns {Date} the date is the next day of week
 * @throws {TypeError} 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 20, 2020?
 * const result = nextDay(new Date(2020, 2, 20), 1)
 * => new Date(2020, 2, 23)
 *
 * @example
 * When is the next Tuesday after Mar, 21, 2020?
 * const result = nextDay(new Date(2020, 2, 21), 2)
 * => new Date(2020, 2, 24)
 **/

export default function nextDay(date: Date | number, day: number): Date {
  requiredArgs(2, arguments)
  // Throw an exception `Invalid Day` if the day is out or range
  if (!baseMap.includes(day + 1)) {
    throw new RangeError('Invalid Day')
  }

  if (!isValid(date)) {
    throw new RangeError('Invalid Date')
  }

  const map = genMap(day)
  return addDays(toDate(date), map[getDay(toDate(date))])
}

function genMap(daysToMove: number): number[] {
  if (daysToMove === 0) {
    return baseMap
  } else {
    const mapStart = baseMap.slice(-daysToMove)
    const mapEnd = baseMap.slice(0, baseMap.length - daysToMove)
    return mapStart.concat(mapEnd)
  }
}


Review comment (suggestion):
Instead of adding runtime checks and adding extra bytes, let's give users a choice, use TypeScript/Flow or getting obscure errors when they misuse the API.

Code after:
 *
 * @description
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
 *
 * @param {Date | number} date - the date to check
 * @param {Day} day - day of the week
 * @returns {Date} - the date is the next day of week
 * @throws {TypeError} - 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 20, 2020?
 * const result = nextDay(new Date(2020, 2, 20), 1)
 * => Mon Mar 23 2020 00:00:00
 *
 * @example
 * When is the next Tuesday after Mar, 21, 2020?
 * const result = nextDay(new Date(2020, 2, 21), 2)
 * => Tue Mar 24 2020 00:00:00
 **/

export default function nextDay(date: Date | number, day: Day): Date {
  requiredArgs(2, arguments)
  const map = genMap(day)
  return addDays(toDate(date), map[getDay(toDate(date))])
}

function genMap(daysToMove: number): number[] {
  if (daysToMove === 0) {
    return baseMap
  } else {
    const mapStart = baseMap.slice(-daysToMove)
    const mapEnd = baseMap.slice(0, baseMap.length - daysToMove)
    return mapStart.concat(mapEnd)
  }
}
Repository: date-fns/date-fns
File: src/nextDay/index.ts (TypeScript)

Code before:
import isValid from '../isValid/index'

const baseMap = [7, 6, 5, 4, 3, 2, 1]

/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of Week?
 *
 * @description
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
 *
 * @param {Date | number} date - the date to check
 * @param {number} day - day of week
 * @returns {Date} the date is the next day of week
 * @throws {TypeError} 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 20, 2020?
 * const result = nextDay(new Date(2020, 2, 20), 1)
 * => new Date(2020, 2, 23)
 *
 * @example
 * When is the next Tuesday after Mar, 21, 2020?
 * const result = nextDay(new Date(2020, 2, 21), 2)
 * => new Date(2020, 2, 24)
 **/

export default function nextDay(date: Date | number, day: number): Date {
  requiredArgs(2, arguments)
  // Throw an exception `Invalid Day` if the day is out or range
  if (!baseMap.includes(day + 1)) {
    throw new RangeError('Invalid Day')
  }

  if (!isValid(date)) {
    throw new RangeError('Invalid Date')
  }

  const map = genMap(day)
  return addDays(toDate(date), map[getDay(toDate(date))])
}

function genMap(daysToMove: number): number[] {
  if (daysToMove === 0) {
    return baseMap
  } else {
    const mapStart = baseMap.slice(-daysToMove)
    const mapEnd = baseMap.slice(0, baseMap.length - daysToMove)
    return mapStart.concat(mapEnd)
  }

Review comment (suggestion):
Please make the example consistent with other functions (see for example `addDays`: https://github.com/date-fns/date-fns/blob/master/src/addDays/index.ts#L25).

Just use `toString` on the date and cut off the timezone (to make it universal):

```js
new Date(2020, 2, 24).toString()
//=> "Tue Mar 24 2020 00:00:00 GMT+0800 (Singapore Standard Time)"
```

Code after:
import { Day } from '../types'

const baseMap = [7, 6, 5, 4, 3, 2, 1]

/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of the week?
 *
 * @description
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
 *
 * @param {Date | number} date - the date to check
 * @param {Day} day - day of the week
 * @returns {Date} - the date is the next day of week
 * @throws {TypeError} - 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 20, 2020?
 * const result = nextDay(new Date(2020, 2, 20), 1)
 * => Mon Mar 23 2020 00:00:00
 *
 * @example
 * When is the next Tuesday after Mar, 21, 2020?
 * const result = nextDay(new Date(2020, 2, 21), 2)
 * => Tue Mar 24 2020 00:00:00
 **/

export default function nextDay(date: Date | number, day: Day): Date {
  requiredArgs(2, arguments)
  const map = genMap(day)
  return addDays(toDate(date), map[getDay(toDate(date))])
}

function genMap(daysToMove: number): number[] {
  if (daysToMove === 0) {
    return baseMap
  } else {
    const mapStart = baseMap.slice(-daysToMove)
    const mapEnd = baseMap.slice(0, baseMap.length - daysToMove)
    return mapStart.concat(mapEnd)
  }
}
Repository: date-fns/date-fns
File: src/nextDay/index.ts (TypeScript)

Code before:
import requiredArgs from '../_lib/requiredArgs/index'
import getDay from '../getDay'
import addDays from '../addDays'
import toDate from '../toDate'
import isValid from '../isValid/index'

const baseMap = [7, 6, 5, 4, 3, 2, 1]

/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of Week?
 *
 * @description
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
 *
 * @param {Date | number} date - the date to check
 * @param {number} day - day of week
 * @returns {Date} the date is the next day of week
 * @throws {TypeError} 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 20, 2020?
 * const result = nextDay(new Date(2020, 2, 20), 1)
 * => new Date(2020, 2, 23)
 *
 * @example
 * When is the next Tuesday after Mar, 21, 2020?
 * const result = nextDay(new Date(2020, 2, 21), 2)
 * => new Date(2020, 2, 24)
 **/

export default function nextDay(date: Date | number, day: number): Date {
  requiredArgs(2, arguments)
  // Throw an exception `Invalid Day` if the day is out or range
  if (!baseMap.includes(day + 1)) {
    throw new RangeError('Invalid Day')

Review comment (suggestion):
```suggestion
 * @summary When is the next day of the week?
```

Code after:
import requiredArgs from '../_lib/requiredArgs/index'
import getDay from '../getDay'
import addDays from '../addDays'
import toDate from '../toDate'
import { Day } from '../types'

const baseMap = [7, 6, 5, 4, 3, 2, 1]

/**
 * @name nextDay
 * @category Weekday Helpers
 * @summary When is the next day of the week?
 *
 * @description
 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
 *
 * @param {Date | number} date - the date to check
 * @param {Day} day - day of the week
 * @returns {Date} - the date is the next day of week
 * @throws {TypeError} - 2 arguments required
 *
 * @example
 * When is the next Monday after Mar, 20, 2020?
 * const result = nextDay(new Date(2020, 2, 20), 1)
 * => Mon Mar 23 2020 00:00:00
 *
 * @example
 * When is the next Tuesday after Mar, 21, 2020?
 * const result = nextDay(new Date(2020, 2, 21), 2)
 * => Tue Mar 24 2020 00:00:00
 **/

export default function nextDay(date: Date | number, day: Day): Date {
  requiredArgs(2, arguments)
  const map = genMap(day)
  return addDays(toDate(date), map[getDay(toDate(date))])
}
Repository: date-fns/date-fns
File: src/isEqual/index.ts (TypeScript)

Code before:
 *
 * @description
 * Are the given dates equal?
 *
 * ### v2.0.0 breaking changes:
 *
 * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
 *
 * @param {Date|Number} dateLeft - the first date to compare
 * @param {Date|Number} dateRight - the second date to compare
 * @returns {Boolean} the dates are equal
 * @throws {TypeError} 2 arguments required
 *
 * @example
 * // Are 2 July 2014 06:30:45.000 and 2 July 2014 06:30:45.500 equal?
 * var result = isEqual(
 *   new Date(2014, 6, 2, 6, 30, 45, 0),
 *   new Date(2014, 6, 2, 6, 30, 45, 500)
 * )
 * //=> false
 */
export default function isEqual(dirtyLeftDate: Date | number, dirtyRightDate: Date | number): boolean {
  requiredArgs(2, arguments)

  const dateLeft: Date = toDate(dirtyLeftDate)
  const dateRight: Date = toDate(dirtyRightDate)
  return dateLeft.getTime() === dateRight.getTime()
}


Review comment (suggestion):
I don't think it's required, could you please confirm?

```suggestion
  const dateLeft = toDate(dirtyLeftDate)
  const dateRight = toDate(dirtyRightDate)
```

Code after:
 *
 * @description
 * Are the given dates equal?
 *
 * ### v2.0.0 breaking changes:
 *
 * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
 *
 * @param {Date|Number} dateLeft - the first date to compare
 * @param {Date|Number} dateRight - the second date to compare
 * @returns {Boolean} the dates are equal
 * @throws {TypeError} 2 arguments required
 *
 * @example
 * // Are 2 July 2014 06:30:45.000 and 2 July 2014 06:30:45.500 equal?
 * var result = isEqual(
 *   new Date(2014, 6, 2, 6, 30, 45, 0),
 *   new Date(2014, 6, 2, 6, 30, 45, 500)
 * )
 * //=> false
 */
export default function isEqual(dirtyLeftDate: Date | number, dirtyRightDate: Date | number): boolean {
  requiredArgs(2, arguments)

  const dateLeft = toDate(dirtyLeftDate)
  const dateRight = toDate(dirtyRightDate)
  return dateLeft.getTime() === dateRight.getTime()
}
Repository: date-fns/date-fns
File: src/isLeapYear/index.ts (TypeScript)

Code before:
import toDate from '../toDate/index'
import requiredArgs from '../_lib/requiredArgs/index'

/**
 * @name isLeapYear
 * @category Year Helpers
 * @summary Is the given date in the leap year?
 *
 * @description
 * Is the given date in the leap year?
 *
 * ### v2.0.0 breaking changes:
 *
 * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
 *
 * @param {Date|Number} dirtyDate - the date to check
 * @returns {Boolean} the date is in the leap year
 * @throws {TypeError} 1 argument required
 *
 * @example
 * // Is 1 September 2012 in the leap year?
 * var result = isLeapYear(new Date(2012, 8, 1))
 * //=> true
 */
export default function isLeapYear(dirtyDate: Date | number): boolean {
  requiredArgs(1, arguments)

  const date = toDate(dirtyDate)
  const year = date.getFullYear()
  return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)
}


Review comment (suggestion):
```suggestion
 * @param {Date|Number} date- the date to check
```

Code after:
import toDate from '../toDate/index'
import requiredArgs from '../_lib/requiredArgs/index'

/**
 * @name isLeapYear
 * @category Year Helpers
 * @summary Is the given date in the leap year?
 *
 * @description
 * Is the given date in the leap year?
 *
 * ### v2.0.0 breaking changes:
 *
 * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
 *
 * @param {Date|Number} date - the date to check
 * @returns {Boolean} the date is in the leap year
 * @throws {TypeError} 1 argument required
 *
 * @example
 * // Is 1 September 2012 in the leap year?
 * var result = isLeapYear(new Date(2012, 8, 1))
 * //=> true
 */
export default function isLeapYear(dirtyDate: Date | number): boolean {
  requiredArgs(1, arguments)

  const date = toDate(dirtyDate)
  const year = date.getFullYear()
  return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)
}