reusing-calendars

A small JavaScript package to get the future/past years in which you could reuse a year's calendar (the dates are repeated.)

Usage no npm install needed!

<script type="module">
  import reusingCalendars from 'https://cdn.skypack.dev/reusing-calendars';
</script>

README

reusing-calendars

A small JavaScript package to get the future/past years in which you could reuse a year's calendar (the dates are repeated.)

Installation

npm install reusing-calendars

Usage

const reusingCalendars = require("reusing-calendars")
var repetitions = reusingCalendars(year, time, count)

Parameters

If a parameter is falsy, the default value will be used. If a parameter is incorrectly specified, a TypeError will be thrown.

Year

Type: Number
Possible values: Any integer
Default value: Current year (new Date().getFullYear())

The year whose dates will be searched for repetitions.

var repetitions = reusingCalendars(2020)
console.log(repetitions)
    // => [ 2048 ]

Time

Type: String
Possible values: "past" or "future"
Default value: "future"

The time in which the repetitions will be searched.

var repetitions = reusingCalendars(2019, "past")
console.log(repetitions)
    // => [ 2013 ]

Count

Type: Number
Possible values: Any natural number
Default value: 1

The number of repetitions returned.

var repetitions = reusingCalendars(1998, "future", 5)
console.log(repetitions)
    // => [ 2009, 2015, 2026, 2037, 2043 ]

Return value

Type: Array

An array will be returned containing the repetitions found, even if count is 1.

Some more examples


// Functions executed in 2019

console.log(reusingCalendars(null, null, 100))
    // => [ 2030, 2041, 2047, 2058, 2069, 2075, 2086, 2097, 2109, 2115, ...90 more ]

console.log(reusingCalendars(null, "past", 3))
    // => [ 2013, 2002, 1991 ]

console.log(reusingCalendars(2000, "future", 5))
    // => [ 2028, 2056, 2084, 2124, 2152 ]

console.log(reusingCalendars())
    // => [ 2030 ]