| 5500 | } |
| 5501 | |
| 5502 | function toISOString$1() { |
| 5503 | // for ISO strings we do not use the normal bubbling rules: |
| 5504 | // * milliseconds bubble up until they become hours |
| 5505 | // * days do not bubble at all |
| 5506 | // * months bubble up until they become years |
| 5507 | // This is because there is no context-free conversion between hours and days |
| 5508 | // (think of clock changes) |
| 5509 | // and also not between days and months (28-31 days per month) |
| 5510 | if (!this.isValid()) { |
| 5511 | return this.localeData().invalidDate(); |
| 5512 | } |
| 5513 | |
| 5514 | var seconds = abs$1(this._milliseconds) / 1000, |
| 5515 | days = abs$1(this._days), |
| 5516 | months = abs$1(this._months), |
| 5517 | minutes, |
| 5518 | hours, |
| 5519 | years, |
| 5520 | s, |
| 5521 | total = this.asSeconds(), |
| 5522 | totalSign, |
| 5523 | ymSign, |
| 5524 | daysSign, |
| 5525 | hmsSign; |
| 5526 | |
| 5527 | if (!total) { |
| 5528 | // this is the same as C#'s (Noda) and python (isodate)... |
| 5529 | // but not other JS (goog.date) |
| 5530 | return 'P0D'; |
| 5531 | } |
| 5532 | |
| 5533 | // 3600 seconds -> 60 minutes -> 1 hour |
| 5534 | minutes = absFloor(seconds / 60); |
| 5535 | hours = absFloor(minutes / 60); |
| 5536 | seconds %= 60; |
| 5537 | minutes %= 60; |
| 5538 | |
| 5539 | // 12 months -> 1 year |
| 5540 | years = absFloor(months / 12); |
| 5541 | months %= 12; |
| 5542 | |
| 5543 | // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js |
| 5544 | s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : ''; |
| 5545 | |
| 5546 | totalSign = total < 0 ? '-' : ''; |
| 5547 | ymSign = sign(this._months) !== sign(total) ? '-' : ''; |
| 5548 | daysSign = sign(this._days) !== sign(total) ? '-' : ''; |
| 5549 | hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : ''; |
| 5550 | |
| 5551 | return ( |
| 5552 | totalSign + |
| 5553 | 'P' + |
| 5554 | (years ? ymSign + years + 'Y' : '') + |
| 5555 | (months ? ymSign + months + 'M' : '') + |
| 5556 | (days ? daysSign + days + 'D' : '') + |
| 5557 | (hours || minutes || seconds ? 'T' : '') + |
| 5558 | (hours ? hmsSign + hours + 'H' : '') + |
| 5559 | (minutes ? hmsSign + minutes + 'M' : '') + |