Last active
December 26, 2015 14:39
-
-
Save jmrocela/7167271 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var iso8601 = require('./iso8601-durations.js'); | |
// Create a new ISO8601 date | |
var isoDate = new iso8601('R5/2013-12-23T19:30:08Z/P1Y2M10DT2H30M'); | |
// Get Date | |
// ISO8601.getDate() returns a native Javascript Date object | |
console.log('The time now is ' + isoDate.getDate()); | |
// Get Date with formatting (requires moment.js) | |
console.log('The time now is ' + isoDate.getDate().format('YYYY-MM-DD HH:mm:ss')); | |
// Get Number of Repeats | |
// ISO8601.getRepeats() | |
console.log('This Date of ' + isoDate.getDate() + ' needs to repeat ' + isoDate.getRepeat() + ' times.'); | |
// Get the Duration of the Interval | |
// ISO8601.getDuration() | |
console.log('This date will be relevant in ' + isoDate.getDuration().toString()); | |
// Get Date of Next Interval | |
// ISO8601.getNextDate() | |
console.log('This date will invoke something on ' + isoDate.getNextDate().format('YYYY-MM-DD HH:mm:ss')); | |
// Get Date of Next Interval of the Next 5 Repeats | |
var intervals = isoDate.getNextDate(5); | |
intervals.forEach(function(interval) { | |
console.log('Interval on ' + interval.format('YYYY-MM-DD HH:mm:ss')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment