Sha256: a39ef9be9b32ad02e062b8e2c2a6e79fdfe9be15fbee870fdac1c62ae938f330
Contents?: true
Size: 823 Bytes
Versions: 9
Compression:
Stored size: 823 Bytes
Contents
var abs = Math.abs; export function toISOString() { // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js var Y = abs(this.years()); var M = abs(this.months()); var D = abs(this.days()); var h = abs(this.hours()); var m = abs(this.minutes()); var s = abs(this.seconds() + this.milliseconds() / 1000); var total = this.asSeconds(); if (!total) { // this is the same as C#'s (Noda) and python (isodate)... // but not other JS (goog.date) return 'P0D'; } return (total < 0 ? '-' : '') + 'P' + (Y ? Y + 'Y' : '') + (M ? M + 'M' : '') + (D ? D + 'D' : '') + ((h || m || s) ? 'T' : '') + (h ? h + 'H' : '') + (m ? m + 'M' : '') + (s ? s + 'S' : ''); }
Version data entries
9 entries across 9 versions & 3 rubygems