Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ultirequiem/leap-year

❓ Check if a year is a leap year
https://github.com/ultirequiem/leap-year

deno javascript leap-year leap-year-check leap-year-or-not nodejs typescript

Last synced: about 21 hours ago
JSON representation

❓ Check if a year is a leap year

Awesome Lists containing this project

README

        

# leap-year

[![Code Coverage](https://codecov.io/gh/ultirequiem/leap-year/branch/main/graph/badge.svg)](https://codecov.io/gh/ultirequiem/leap-year)
[![Deno Docs](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/leap_year/mod.ts)

Check if a year is a [leap year](https://en.wikipedia.org/wiki/Leap_year),
that's a calendar year that contains an additional day added to keep the
calendar year synchronized with the astronomical year or seasonal year.

## Usage

### [Deno 🦕](https://deno.land/x/leap_year)

```javascript
import { isLeapYear } from "https://deno.land/x/leap_year/mod.ts";

isLeapYear(2014); //=> false
isLeapYear(2016); //=> true
isLeapYear("6 October 2006 00:07:00 GMT"); //=> false
isLeapYear("2000"); //=> false
isLeapYear(new Date(2016, 1, 1)); //=> true
isLeapYear("13 December 400 00:07:00 GMT", true); //=> { year: 400, result: true }
```

### [Node.js 🐢🚀](https://www.npmjs.com/package/@ultirequiem/leap-year)

```typescript
import { isLeapYear } from "@ultirequiem/leap-year";
```

### [Browser 🌐](https://developer.mozilla.org/en-US/docs/Glossary/Browser)

You can use any [CDN](https://en.wikipedia.org/wiki/Content_delivery_network) 🔥

Eg. [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
▶ [SkyPack](https://cdn.skypack.dev/@ultirequiem/leap-year) _/_
[script tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) ▶
[JSDelivr](https://cdn.jsdelivr.net/npm/@ultirequiem/leap-year).

The API is the same on all this platforms.

## API

[Autogenerated Documentation](https://doc.deno.land/https://deno.land/x/leap_year/mod.ts)
🚀

## CLI Tool

Was done mainly as usage example.

### Install

- Node.js 🦍

```sh
npm install -g @ultirequiem/leap-year
```

- Deno 🦕

```sh
deno install https://deno.land/x/leap_year/leap-year.ts
```

### Usage

```sh
leap-year "13 October 2020 00:07:00 GMT" 400 345
true
true
false
```

Or with the verbose flag 👇

```sh
leap-year "13 October 2020 00:07:00 GMT" 400 345 --verbose # -v
2020 is a leap year.
400 is a leap year.
345 is not a leap year.
```

## Related

- [leap_year_utils](https://github.com/UltiRequiem/leap_year_utils): Utilities
around this package.

- [parse_datelike](https://github.com/UltiRequiem/parse_datelike): Parse a
number/string/date to a number/string/date.

- [leap-year-api](https://github.com/UltiRequiem/leap-year-api): A REST API to
know if a year is leap or not.

## Support

Open an Issue, I will check it a soon as possible 👀

If you want to hurry me up a bit
[send me a tweet](https://twitter.com/UltiRequiem) 😆

Consider [supporting me on Patreon](https://patreon.com/UltiRequiem) if you like
my work 🙏

Don't forget to star the repo ⭐

## Versioning

We use [Semantic Versioning](http://semver.org). For the versions available, see
the [tags](https://github.com/UltiRequiem/leap-year/tags) 🏷️

## Licence

Licensed under the MIT License 📄