Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjirou/within-one-year
A module to judge whether it is within one year
https://github.com/kjirou/within-one-year
Last synced: 12 days ago
JSON representation
A module to judge whether it is within one year
- Host: GitHub
- URL: https://github.com/kjirou/within-one-year
- Owner: kjirou
- Created: 2017-01-11T10:44:18.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-08-31T07:46:38.000Z (about 3 years ago)
- Last Synced: 2024-10-12T01:18:15.343Z (27 days ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# within-one-year
[![npm version](https://badge.fury.io/js/within-one-year.svg)](https://badge.fury.io/js/within-one-year)
A module to judge whether it is within one year
## Installation
```bash
npm install within-one-year
```## Usage
```js
const withinOneYear = require('within-one-year');const from = new Date('2017-01-01T00:00:00.000Z');
console.log(withinOneYear(from, new Date('2018-01-01T00:00:00.000Z'))); // -> true
console.log(withinOneYear(from, new Date('2018-01-01T00:00:00.001Z'))); // -> false
```## Interpretation of leap years
- `2016-02-29 + 1 year` => `2017-03-01`
- `2015-03-01 + 1 year` => `2016-03-01`
- `2015-02-28 + 1 year` => `2016-02-28`