@smhg/date-interval
Algebraic operations for time intervals
Last updated 21 days ago by smhg .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @smhg/date-interval 
SYNC missed versions from official npm registry.

date-interval Build status

Algebraic operations for time intervals.

Installation

$ npm install @smhg/date-interval

Usage

import Interval from '@smhg/date-interval';

// with ISO 8601 string
let interval1 = Interval('2015-08-03T12:00:00Z/2015-08-04T12:00:00Z');

// with 2 dates
let interval2 = Interval(new Date('2015-08-03T12:00:00Z'), new Date('2015-08-04T12:00:00Z'));

API

Interval()

Interval(String)

Pass an ISO 8601 time interval formatted string to create an interval.

Interval(Date, Date)

Pass a start and end Date object to create an interval.

interval.toString()

Returns the interval as an ISO 8601 formatted string.

interval.overlaps(Interval)

Returns whether both intervals overlap.

interval.union(Interval)

Returns an array with the result of a merge of both intervals.

interval.diff(Interval)

Returns an array with the difference of both intervals.

interval.intersection(Interval)

Returns the interval that lies at the intersection of both intervals (if any).

Current Tags

  • 1.3.0                                ...           latest (21 days ago)

18 Versions

  • 1.3.0                                ...           21 days ago
  • 1.2.2                                ...           7 months ago
  • 1.2.1                                ...           7 months ago
  • 1.2.0                                ...           7 months ago
  • 1.1.5                                ...           2 years ago
  • 1.1.4                                ...           2 years ago
  • 1.1.3                                ...           2 years ago
  • 1.1.2                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           3 years ago
  • 0.2.3                                ...           4 years ago
  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 24
Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |