0.4.1 • Published 8 years ago

@datatypes/interval v0.4.1

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

Interval

Module for ISO 8601 based intervals and recurring intervals.

Installation

npm install --save @datatypes/interval

Usage

As separator string it can either be used -- or /. It's recommended to use -- due to the possibility to use it in file names and URLs.

Import interval into your modules like this (ES2015 style):

import Interval, {RecurringInterval} from '@datatypes/interval'

<start moment>--<end moment>

const interval = new Interval('2015-09--2015-11')
const intervalObject = {
	string: test.title,
	start: momentFromString('2015-09'),
	end: momentFromString('2015-11'),
	duration: new Duration('P2184H0M0.0S'),
}

assert.deepEqual(interval.object, intervalObject)

<start moment>--<incomplete end moment>

const interval = new Interval('2015-11-24--30')
const intervalObject = {
	string: test.title,
	start: momentFromString('2015-11-24'),
	end: momentFromString('2015-11-30'),
	duration: new Duration('P168H0M0.0S'),
}

assert.deepEqual(interval.object, intervalObject)

R<number of recurrences>--<start moment>--<duration>

const recurringInterval = new RecurringInterval('R3--2015-11-25T15--P1H30M')
const recurringIntervalObject = {
	string: 'R3--2015-11-25T15--P1H30M',
	numberOfRecurrences: 3,
	start:  momentFromString('2015-11-25T15'),
	end: momentFromString('2015-11-25T16:30'),
	duration: new Duration('P1H30M')
}

assert.deepEqual(recurringInterval.object, recurringIntervalObject)

Check out the test directory for more usage examples!

0.4.1

8 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago