Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seikho/date-equality
https://github.com/seikho/date-equality
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/seikho/date-equality
- Owner: Seikho
- Created: 2015-10-16T03:37:22.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-19T06:58:25.000Z (about 9 years ago)
- Last Synced: 2024-10-14T14:34:13.747Z (23 days ago)
- Language: JavaScript
- Size: 164 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
### Date Equality
Broader date equality checking and mutating### Installation
```
npm install --save date-equality
```### Usage
In the browser:
```html```
Node/RequireJS
```javascript
// Typescript/ES6
import * as DE from 'date-equality';// ES5
var DE = require('date-equality');
```### API
#### sameDate
Returns true if the two provided `Date` objects are on the same date
```javascript
function sameDate(left: Date, right: Date): boolean;
```Returns true if the two provided `Date` objects are in the same week
#### sameWeek
```javascript
function sameWeek(left: Date, right: Date, startOfWeek?: number): boolean;
```Returns true if the two provided `Date` objects have the same time (second precision)
#### sameDateTime
```javascript
function sameDateTime(left: Date, right: Date): boolean;
```#### floorDay
Returns a new `Date` object that is the start (00h00m00s000ms) of the provided `Date` object
```javascript
function floorDay(date: Date): Date;
```#### ceilDay
Returns a new `Date` object that is the end (23h59m59s999ms) of the provided `Date` object
```javascript
function ceilDay(date: Date): Date;
```#### floorWeek
Returns a new `Date` object that is the beginning of the week and floored (`floorDay(Date)`)
```javascript
function floorWeek(date: Date, startOfWeek?: number): Date;
```#### ceilWeek
Returns a new `Date` object that is the end of the week and ceiled (`ceilDay(Date)`)
```javascript
function ceilWeek(date: Date, startOfWeek?: number): Date;
```#### dateRange
Returns the lower and upper bounds as a `DateRange` object from an array of `Date` objects
```javascript
function dateRange(dates: Array): DateRange;
```#### inRange
Returns true if the provided `Date` object is in the `DateRange` provided
```javascript
function inRange(date: Date, range: DateRange): boolean;
```#### DateRange
```javascript
interface DateRange {
start: Date;
end: Date;
}
```