js-joda
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -1,1 +0,2 @@ | ||
var jsjoda=function(e){function t(a){if(n[a])return n[a].exports;var i=n[a]={exports:{},id:a,loaded:!1};return e[a].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=n(1);t["default"]={LocalDate:a.LocalDate},e.exports=t["default"]},function(e,t,n){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(2),u=n(3),l=n(4),o=n(5),s=146097,c=5*s-10957,f=function(){function e(t,n,i){a(this,e),e.validate(t,n,i),this._year=t,this._month=n,this._day=i}return i(e,[{key:"year",value:function(){return this._year}},{key:"month",value:function(){return this._month}},{key:"day",value:function(){return this._day}},{key:"plusDays",value:function(t){if(0===t)return this;var n=this.toEpochDay()+t;return e.ofEpochDay(n)}},{key:"toEpochDay",value:function(){var e=this.year(),t=this.month(),n=0;return n+=365*e,e>=0?n+=u.MathUtil.div(e+3,4)-u.MathUtil.div(e+99,100)+u.MathUtil.div(e+399,400):n-=u.MathUtil.div(e,-4)-u.MathUtil.div(e,-100)+u.MathUtil.div(e,-400),n+=u.MathUtil.div(367*t-362,12),n+=this.day()-1,t>2&&(n--,l.IsoChronology.isLeapYear(e)||n--),n-c}},{key:"toString",value:function(){var e,t,n,a=this.year(),i=this.month(),r=this.day(),u=Math.abs(a);return n=1e3>u?0>a?"-"+(""+(a-1e4)).slice(-4):(""+(a+1e4)).slice(-4):a>9999?"+"+a:""+a,t=10>i?"-0"+i:"-"+i,e=10>r?"-0"+r:"-"+r,n+t+e}}],[{key:"ofEpochDay",value:function(t){var n,a,i,r,l,o,f,h,m,v;return v=t+c,v-=60,n=0,0>v&&(a=u.MathUtil.div(v+1,s)-1,n=400*a,v+=-a*s),m=u.MathUtil.div(400*v+591,s),r=v-(365*m+u.MathUtil.div(m,4)-u.MathUtil.div(m,100)+u.MathUtil.div(m,400)),0>r&&(m--,r=v-(365*m+u.MathUtil.div(m,4)-u.MathUtil.div(m,100)+u.MathUtil.div(m,400))),m+=n,l=r,o=u.MathUtil.div(5*l+2,153),f=(o+2)%12+1,i=l-u.MathUtil.div(306*o+5,10)+1,m+=u.MathUtil.div(o,10),h=m,new e(h,f,i)}},{key:"validate",value:function(e,t,n){var a;if(o.YEAR.checkValidValue(e),o.MONTH_OF_YEAR.checkValidValue(t),o.DAY_OF_MONTH.checkValidValue(n),n>28){switch(a=31,t){case 2:a=l.IsoChronology.isLeapYear(e)?29:28;break;case 4:case 6:case 9:case 11:a=30}n>a&&(29===n?r.assert(!1,"Invalid date 'February 29' as '"+e+"' is not a leap year"):r.assert(!1,"Invalid date '"+e+"' '"+t+"' '"+n+"'"))}}}]),e}();t.LocalDate=f},function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.assert=n},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),i=function(){function e(){n(this,e)}return a(e,null,[{key:"div",value:function(e,t){return~~(e/t)}}]),e}();t.MathUtil=i},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),i=function(){function e(){n(this,e)}return a(e,null,[{key:"isLeapYear",value:function(e){return 0===(3&e)&&(e%100!==0||e%400===0)}}]),e}();t.IsoChronology=i},function(e,t,n){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(6),u=function(){function e(t,n,i,r,u){a(this,e),this.name=function(){return t},this.baseUnit=function(){return n},this.rangeUnit=function(){return i},this.range=function(){return r},this.displayNameKey=function(){return u}}return i(e,[{key:"checkValidValue",value:function(e){return this.range().checkValidValue(e,this.name())}}]),e}(),l=new u("DayOfMonth",null,null,r.ValueRange.of(1,28,31),"day");t.DAY_OF_MONTH=l;var o=new u("MonthOfYear",null,null,r.ValueRange.of(1,12),"month");t.MONTH_OF_YEAR=o;var s=new u("Year",null,null,r.ValueRange.of(-999999,999999),"year");t.YEAR=s},function(e,t,n){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(2),u=function(){function e(t,n,i,u){a(this,e),r.assert(!(t>n),"Smallest minimum value '"+t+"' must be less than largest minimum value '"+n+"'"),r.assert(!(i>u),"Smallest maximum value '"+i+"' must be less than largest maximum value '"+u+"'"),r.assert(!(n>u),"Minimum value '"+n+"' must be less than maximum value '"+u+"'"),this.minimum=function(){return t},this.largestMinimum=function(){return n},this.maximum=function(){return u},this.smallestMaximum=function(){return i}}return i(e,[{key:"isValidValue",value:function(e){return this.minimum()<=e&&e<=this.maximum()}},{key:"checkValidValue",value:function(e,t){var n;return this.isValidValue(e)?void 0:(n=null!=t?"Invalid value for "+t+" (valid values "+this.toString()+"): "+e:"Invalid value (valid values "+this.toString()+"): "+e,r.assert(!1,n))}},{key:"toString",value:function(){var e=this.minimum()+(this.minimum()!==this.largestMinimum()?"/"+this.largestMinimum():"");return e+=" - ",e+=this.smallestMaximum()+(this.smallestMaximum()!==this.maximum()?"/"+this.maximum():"")}}],[{key:"of",value:function(){return 2===arguments.length?new e(arguments[0],arguments[0],arguments[1],arguments[1]):3===arguments.length?new e(arguments[0],arguments[0],arguments[1],arguments[2]):4===arguments.length?new e(arguments[0],arguments[1],arguments[2],arguments[3]):r.assert(!1,"Invalid number of arguments "+arguments.length)}}]),e}();t.ValueRange=u}]); | ||
var jsjoda=function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(1);Object.defineProperty(t,"LocalDate",{enumerable:!0,get:function(){return o.LocalDate}});var r=n(12);Object.defineProperty(t,"Instant",{enumerable:!0,get:function(){return r.Instant}});var i=n(11);Object.defineProperty(t,"Clock",{enumerable:!0,get:function(){return i.Clock}});var a=n(18);Object.defineProperty(t,"ZoneOffset",{enumerable:!0,get:function(){return a.ZoneOffset}})},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.LocalDate=void 0;var i=n(2),a=n(5),u=n(3),s=n(6),l=n(7),c=n(11),f=n(19),h=n(10),E=n(15),d=146097,p=5*d-10957,v=t.LocalDate=function(){function e(t,n,r){o(this,e),n instanceof f.Month&&(n=n.value()),e.validate(t,n,r),this._year=t,this._month=n,this._day=r}return r(e,[{key:"year",value:function(){return this._year}},{key:"monthValue",value:function(){return this._month}},{key:"month",value:function(){return f.Month.of(this._month)}},{key:"dayOfMonth",value:function(){return this._day}},{key:"plusDays",value:function(t){if(0===t)return this;var n=this.toEpochDay()+t;return e.ofEpochDay(n)}},{key:"minusDays",value:function(e){return this.plusDays(-1*e)}},{key:"toEpochDay",value:function(){var e=this.year(),t=this.monthValue(),n=0;return n+=365*e,e>=0?n+=a.MathUtil.intDiv(e+3,4)-a.MathUtil.intDiv(e+99,100)+a.MathUtil.intDiv(e+399,400):n-=a.MathUtil.intDiv(e,-4)-a.MathUtil.intDiv(e,-100)+a.MathUtil.intDiv(e,-400),n+=a.MathUtil.intDiv(367*t-362,12),n+=this.dayOfMonth()-1,t>2&&(n--,s.IsoChronology.isLeapYear(e)||n--),n-p}},{key:"equals",value:function(t){return this===t?!0:t instanceof e?0===this._compareTo(t):!1}},{key:"_compareTo",value:function(e){var t=this.year()-e.year();return 0===t&&(t=this.monthValue()-e.monthValue(),0===t&&(t=this.dayOfMonth()-e.dayOfMonth())),t}},{key:"toString",value:function(){var e,t,n,o=this.year(),r=this.monthValue(),i=this.dayOfMonth(),a=Math.abs(o);return n=1e3>a?0>o?"-"+(""+(o-1e4)).slice(-4):(""+(o+1e4)).slice(-4):o>9999?"+"+o:""+o,t=10>r?"-0"+r:"-"+r,e=10>i?"-0"+i:"-"+i,n+t+e}},{key:"withDayOfMonth",value:function(t){return this._day===t?this:e.of(this._year,this._month,t)}},{key:"withMonth",value:function(t){return this._month===t?this:e.of(this._year,t,this._day)}}],[{key:"of",value:function(t,n,o){return new e(t,n,o)}},{key:"now",value:function t(){var n=arguments.length<=0||void 0===arguments[0]?c.Clock.systemDefaultZone():arguments[0],t=n.instant(),o=n.offset(t),r=t.epochSecond()+o.totalSeconds(),i=a.MathUtil.floorDiv(r,E.LocalTime.SECONDS_PER_DAY);return e.ofEpochDay(i)}},{key:"ofEpochDay",value:function(t){var n,o,r,i,u,s,l,c,f,h;return h=t+p,h-=60,n=0,0>h&&(o=a.MathUtil.intDiv(h+1,d)-1,n=400*o,h+=-o*d),f=a.MathUtil.intDiv(400*h+591,d),i=h-(365*f+a.MathUtil.intDiv(f,4)-a.MathUtil.intDiv(f,100)+a.MathUtil.intDiv(f,400)),0>i&&(f--,i=h-(365*f+a.MathUtil.intDiv(f,4)-a.MathUtil.intDiv(f,100)+a.MathUtil.intDiv(f,400))),f+=n,u=i,s=a.MathUtil.intDiv(5*u+2,153),l=(s+2)%12+1,r=u-a.MathUtil.intDiv(306*s+5,10)+1,f+=a.MathUtil.intDiv(s,10),c=f,new e(c,l,r)}},{key:"ofYearDay",value:function(t,n){l.ChronoField.YEAR.checkValidValue(t);var o=s.IsoChronology.isLeapYear(t);366===n&&o===!1&&(0,i.assert)(!1,"Invalid date 'DayOfYear 366' as '"+t+"' is not a leap year",u.DateTimeException);var r=f.Month.of(Math.floor((n-1)/31+1)),a=r.firstDayOfYear(o)+r.length(o)-1;n>a&&(r=r.plus(1));var c=n-r.firstDayOfYear(o)+1;return new e(t,r.value(),c)}},{key:"validate",value:function(e,t,n){var o;if(l.ChronoField.YEAR.checkValidValue(e),l.ChronoField.MONTH_OF_YEAR.checkValidValue(t),l.ChronoField.DAY_OF_MONTH.checkValidValue(n),n>28){switch(o=31,t){case 2:o=s.IsoChronology.isLeapYear(e)?29:28;break;case 4:case 6:case 9:case 11:o=30}n>o&&(29===n?(0,i.assert)(!1,"Invalid date 'February 29' as '"+e+"' is not a leap year",u.DateTimeException):(0,i.assert)(!1,"Invalid date '"+e+"' '"+t+"' '"+n+"'",u.DateTimeException))}}}]),e}();v.MIN=v.of(h.Year.MIN_VALUE,1,1),v.MAX=v.of(h.Year.MAX_VALUE,12,31)},function(e,t,n){"use strict";function o(e,t,n){if(!e)throw n?new n(t):new Error(t)}function r(e,t){if(null==e)throw new i.NullPointerException(t+" must not be null");return e}Object.defineProperty(t,"__esModule",{value:!0}),t.assert=o,t.requireNonNull=r;var i=n(3)},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.NullPointerException=t.ArithmeticException=t.UnsupportedTemporalTypeException=t.DateTimeParseException=t.DateTimeException=void 0;var u=n(4),s=o(u);t.DateTimeException=function(e){function t(){var e=arguments.length<=0||void 0===arguments[0]?"DateTimeException":arguments[0],n=arguments.length<=1||void 0===arguments[1]?null:arguments[1];r(this,t);var o=e;return null!==n&&n instanceof Error&&(o+="\n-------\nCaused by: "+n.stack+"\n-------\n"),i(this,Object.getPrototypeOf(t).call(this,o))}return a(t,e),t}(s["default"]),t.DateTimeParseException=function(e){function t(){var e=arguments.length<=0||void 0===arguments[0]?"DateTimeParseException":arguments[0],n=arguments.length<=1||void 0===arguments[1]?"":arguments[1],o=arguments.length<=2||void 0===arguments[2]?0:arguments[2],a=arguments.length<=3||void 0===arguments[3]?null:arguments[3];r(this,t);var u=e+": "+n+", at index: "+o;return null!==a&&a instanceof Error&&(u+="\n-------\nCaused by: "+a.stack+"\n-------\n"),i(this,Object.getPrototypeOf(t).call(this,u))}return a(t,e),t}(s["default"]),t.UnsupportedTemporalTypeException=function(e){function t(){var e=arguments.length<=0||void 0===arguments[0]?"UnsupportedTemporalTypeException":arguments[0];return r(this,t),i(this,Object.getPrototypeOf(t).call(this,e))}return a(t,e),t}(s["default"]),t.ArithmeticException=function(e){function t(){var e=arguments.length<=0||void 0===arguments[0]?"ArithmeticException":arguments[0];return r(this,t),i(this,Object.getPrototypeOf(t).call(this,e))}return a(t,e),t}(s["default"]),t.NullPointerException=function(e){function t(){var e=arguments.length<=0||void 0===arguments[0]?"NullPointerException":arguments[0];return r(this,t),i(this,Object.getPrototypeOf(t).call(this,e))}return a(t,e),t}(s["default"])},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var r=function(e,t,n){for(var o=!0;o;){var r=e,i=t,a=n;u=l=s=void 0,o=!1,null===r&&(r=Function.prototype);var u=Object.getOwnPropertyDescriptor(r,i);if(void 0!==u){if("value"in u)return u.value;var s=u.get;if(void 0===s)return;return s.call(a)}var l=Object.getPrototypeOf(r);if(null===l)return;e=l,t=i,n=a,o=!0}},i=function(e){function t(){var e=arguments.length<=0||void 0===arguments[0]?"":arguments[0];return n(this,t),r(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),Object.defineProperty(this,"message",{enumerable:!1,value:e}),Object.defineProperty(this,"name",{enumerable:!1,value:this.constructor.name}),Error.hasOwnProperty("captureStackTrace")?void Error.captureStackTrace(this,this.constructor):void Object.defineProperty(this,"stack",{enumerable:!1,value:new Error(e).stack})}return o(t,e),t}(Error);t["default"]=i,e.exports=t["default"]},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.MathUtil=t.MIN_SAFE_INTEGER=t.MAX_SAFE_INTEGER=void 0;var i=n(3),a=t.MAX_SAFE_INTEGER=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:Math.pow(2,53)-1,u=t.MIN_SAFE_INTEGER=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:-(Math.pow(2,53)-1);t.MathUtil=function(){function e(){o(this,e)}return r(e,null,[{key:"intDiv",value:function(e,t){var n=e/t;return 0>n?Math.ceil(n):Math.floor(n)}},{key:"intMod",value:function(t,n){var o=t-e.intDiv(t,n)*n;return 0>o?Math.ceil(o):Math.floor(o)}},{key:"floorDiv",value:function(e,t){var n=Math.floor(e/t);return n}},{key:"floorMod",value:function(t,n){var o=t-e.floorDiv(t,n)*n;return o}},{key:"safeAdd",value:function(e,t){if(0===e){var n=t;if(n>a||u>n)throw new i.ArithmeticException("Invalid addition beyond MAX_SAFE_INTEGER!");return n}if(0===t){var o=e;if(o>a||u>o)throw new i.ArithmeticException("Invalid addition beyond MAX_SAFE_INTEGER!");return o}if(void 0===e||void 0===t)throw new i.ArithmeticException("Invalid addition using undefined as argument");if(isNaN(e)||isNaN(t))throw new i.ArithmeticException("Invalid addition using NaN as argument");var r=e+t;if(r>a||u>r||r===e||r===t)throw new i.ArithmeticException("Invalid addition beyond MAX_SAFE_INTEGER!");return r}},{key:"safeSubtract",value:function(e,t){if(0===e){var n=t;if(n>a||u>n)throw new i.ArithmeticException("Invalid addition beyond MAX_SAFE_INTEGER!");return n}if(0===t){var o=e;if(o>a||u>o)throw new i.ArithmeticException("Invalid addition beyond MAX_SAFE_INTEGER!");return o}if(void 0===e||void 0===t)throw new i.ArithmeticException("Invalid subtraction using undefined as argument");if(isNaN(e)||isNaN(t))throw new i.ArithmeticException("Invalid subtraction using NaN as argument");var r=e-t;if(u>r||r>a||r===e||r===t)throw new i.ArithmeticException("Invalid subtraction beyond MIN_SAFE_INTEGER!");return r}},{key:"safeMultiply",value:function(e,t){if(1==e)return t;if(1==t)return e;if(0==e||0==t)return 0;var n=e*t;if(u>n||n>a||n/t!=e||e==u&&-1==t||t==u&&-1==e)throw new i.ArithmeticException("Multiplication overflows: "+e+" * "+t);return n}},{key:"compareNumbers",value:function(e,t){return t>e?-1:e>t?1:0}}]),e}()},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0});var r=t.IsoChronology=function(){function e(){n(this,e)}return o(e,null,[{key:"isLeapYear",value:function(e){return 0===(3&e)&&(e%100!==0||e%400===0)}}]),e}();r.INSTANCE=new r},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.ChronoField=void 0;var u=n(5),s=n(8),l=n(9),c=n(10),f=t.ChronoField=function(e){function t(e,n,i,a,u){o(this,t);var s=r(this,Object.getPrototypeOf(t).call(this));return s.name=function(){return e},s.baseUnit=function(){return n},s.rangeUnit=function(){return i},s.range=function(){return a},s.displayNameKey=function(){return u},s}return i(t,e),a(t,[{key:"checkValidValue",value:function(e){return this.range().checkValidValue(e,this.name())}},{key:"rangeRefinedBy",value:function(e){return e.range(this)}}]),t}(s.TemporalField);f.NANO_OF_SECOND=new f("NanoOfSecond",null,null,l.ValueRange.of(0,999999999)),f.MICRO_OF_SECOND=new f("MicroOfSecond",null,null,l.ValueRange.of(0,999999)),f.MILLI_OF_SECOND=new f("MilliOfSecond",null,null,l.ValueRange.of(0,999)),f.DAY_OF_MONTH=new f("DayOfMonth",null,null,l.ValueRange.of(1,28,31),"day"),f.MONTH_OF_YEAR=new f("MonthOfYear",null,null,l.ValueRange.of(1,12),"month"),f.YEAR=new f("Year",null,null,l.ValueRange.of(c.Year.MIN_VALUE,c.Year.MAX_VALUE),"year"),f.INSTANT_SECONDS=new f("InstantSeconds",null,null,l.ValueRange.of(u.MIN_SAFE_INTEGER,u.MAX_SAFE_INTEGER))},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});t.TemporalField=function o(){n(this,o)}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.ValueRange=void 0;var i=n(2),a=n(3);t.ValueRange=function(){function e(t,n,r,a){o(this,e),(0,i.assert)(!(t>n),"Smallest minimum value '"+t+"' must be less than largest minimum value '"+n+"'"),(0,i.assert)(!(r>a),"Smallest maximum value '"+r+"' must be less than largest maximum value '"+a+"'"),(0,i.assert)(!(n>a),"Minimum value '"+n+"' must be less than maximum value '"+a+"'"),this.minimum=function(){return t},this.largestMinimum=function(){return n},this.maximum=function(){return a},this.smallestMaximum=function(){return r}}return r(e,[{key:"isValidValue",value:function(e){return this.minimum()<=e&&e<=this.maximum()}},{key:"checkValidValue",value:function(e,t){var n;return this.isValidValue(e)?void 0:(n=null!=t?"Invalid value for "+t+" (valid values "+this.toString()+"): "+e:"Invalid value (valid values "+this.toString()+"): "+e,(0,i.assert)(!1,n,a.DateTimeException))}},{key:"toString",value:function(){var e=this.minimum()+(this.minimum()!==this.largestMinimum()?"/"+this.largestMinimum():"");return e+=" - ",e+=this.smallestMaximum()+(this.smallestMaximum()!==this.maximum()?"/"+this.maximum():"")}}],[{key:"of",value:function(){return 2===arguments.length?new e(arguments[0],arguments[0],arguments[1],arguments[1]):3===arguments.length?new e(arguments[0],arguments[0],arguments[1],arguments[2]):4===arguments.length?new e(arguments[0],arguments[1],arguments[2],arguments[3]):(0,i.assert)(!1,"Invalid number of arguments "+arguments.length)}}]),e}()},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=t.Year=function r(){n(this,r)};o.MIN_VALUE=-999999,o.MAX_VALUE=999999},function(e,t,n){"use strict";function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.Clock=void 0;var u=n(12),s=n(18),l=t.Clock=function(){function e(){i(this,e)}return a(e,[{key:"millis",value:function(){throw new TypeError("millis() function is not implemented")}},{key:"instant",value:function(){throw new TypeError("instant() function is not implemented")}},{key:"offset",value:function(){throw new TypeError("offset() function is not implemented")}}],[{key:"systemUTC",value:function(){return new f}},{key:"systemDefaultZone",value:function(){return new h}},{key:"fixed",value:function(e,t){return new E(e,t)}}]),e}(),c=function(e){function t(){return i(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return r(t,e),a(t,[{key:"millis",value:function(){return(new Date).getTime()}},{key:"instant",value:function(){return u.Instant.ofEpochMilli(this.millis())}},{key:"offset",value:function(){return s.ZoneOffset.ofTotalSeconds(0)}}]),t}(l),f=function(e){function t(){return i(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return r(t,e),a(t,[{key:"toString",value:function(){return"SystemClock[UTC]"}}]),t}(c),h=function(e){function t(){return i(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return r(t,e),a(t,[{key:"offset",value:function(e){var t=(new Date).getTimezoneOffset(e.epochMilli());return s.ZoneOffset.ofTotalMinutes(t)}},{key:"toString",value:function(){return"SystemClock[default]"}}]),t}(c),E=function(e){function t(e,n){i(this,t);var r=o(this,Object.getPrototypeOf(t).call(this));return r._instant=e,r._zoneOffset=n,r}return r(t,e),a(t,[{key:"instant",value:function(){return this._instant}},{key:"offset",value:function(){return this._zoneOffset}},{key:"toString",value:function(){return"FixedClock[]"}}]),t}(l)},function(e,t,n){"use strict";function o(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.Instant=void 0;var s=n(7),l=n(13),c=n(11),f=n(3),h=n(15),E=n(5),d=n(16),p=-31619087596800,v=31494784694400,y=1e6,_=t.Instant=function(e){function t(e,n){r(this,t);var o=i(this,Object.getPrototypeOf(t).call(this));return t.validate(e,n),o._seconds=e,o._nanos=n,o}return a(t,e),u(t,[{key:"epochSecond",value:function(){return this._seconds}},{key:"epochMilli",value:function(){return 1e3*this._seconds+this._nanos/1e6}},{key:"nano",value:function(){return this._nanos}},{key:"plusSeconds",value:function(e){return this._plus(e,0)}},{key:"minusSeconds",value:function(e){return this.plusSeconds(-1*e)}},{key:"plusNanos",value:function(e){return this._plus(0,e)}},{key:"_plus",value:function(e,n){if(0==(e|n))return this;var o=this._seconds+e;o+=E.MathUtil.intDiv(n,h.LocalTime.NANOS_PER_SECOND);var r=n%h.LocalTime.NANOS_PER_SECOND,i=this._nanos+r;return t.ofEpochSecond(o,i)}},{key:"equals",value:function(e){return this===e?!0:e instanceof t?this.epochSecond()===e.epochSecond()&&this.nano()===e.nano():!1}},{key:"until",value:function(e,n){var o=t.from(e);if(n instanceof l.ChronoUnit){switch(n){case l.ChronoUnit.NANOS:return this._nanosUntil(o);case l.ChronoUnit.MICROS:return this._nanosUntil(o)/1e3;case l.ChronoUnit.MILLIS:return E.MathUtil.safeSubtract(o.toEpochMilli(),this.toEpochMilli());case l.ChronoUnit.SECONDS:return this._secondsUntil(o);case l.ChronoUnit.MINUTES:return E.MathUtil.intDiv(this._secondsUntil(o),h.LocalTime.SECONDS_PER_MINUTE);case l.ChronoUnit.HOURS:return E.MathUtil.intDiv(this._secondsUntil(o),h.LocalTime.SECONDS_PER_HOUR);case l.ChronoUnit.HALF_DAYS:return E.MathUtil.intDiv(this._secondsUntil(o),12*h.LocalTime.SECONDS_PER_HOUR);case l.ChronoUnit.DAYS:return E.MathUtil.intDiv(this._secondsUntil(o),h.LocalTime.SECONDS_PER_DAY)}throw new f.UnsupportedTemporalTypeException("Unsupported unit: "+n)}return n.between(this,o)}},{key:"_nanosUntil",value:function(e){var t=E.MathUtil.safeSubtract(e.epochSecond(),this.epochSecond()),n=E.MathUtil.safeMultiply(t,h.LocalTime.NANOS_PER_SECOND);return E.MathUtil.safeAdd(n,e.nano()-this.nano())}},{key:"_secondsUntil",value:function(e){var t=E.MathUtil.safeSubtract(e.epochSecond(),this.epochSecond()),n=e.nano()-this.nano();return t>0&&0>n?t--:0>t&&n>0&&t++,t}},{key:"get",value:function(e){if(e instanceof s.ChronoField){switch(e){case s.ChronoField.NANO_OF_SECOND:return this._nanos;case s.ChronoField.MICRO_OF_SECOND:return E.MathUtil.intDiv(this._nanos,1e3);case s.ChronoField.MILLI_OF_SECOND:return E.MathUtil.intDiv(this._nanos,y);case s.ChronoField.INSTANT_SECONDS:s.ChronoField.INSTANT_SECONDS.checkValidIntValue(this._seconds)}throw new f.UnsupportedTemporalTypeException("Unsupported field: "+e)}return this.range(e).checkValidIntValue(e.getFrom(this),e)}},{key:"getLong",value:function(e){if(e instanceof s.ChronoField){switch(e){case s.ChronoField.NANO_OF_SECOND:return this._nanos;case s.ChronoField.MICRO_OF_SECOND:return E.MathUtil.intDiv(this._nanos,1e3);case s.ChronoField.MILLI_OF_SECOND:return E.MathUtil.intDiv(this._nanos,y);case s.ChronoField.INSTANT_SECONDS:return this._seconds}throw new f.UnsupportedTemporalTypeException("Unsupported field: "+e)}return e.getFrom(this)}},{key:"isSupported",value:function(e){return e instanceof s.ChronoField?e===s.ChronoField.INSTANT_SECONDS||e===s.ChronoField.NANO_OF_SECOND||e===s.ChronoField.MICRO_OF_SECOND||e===s.ChronoField.MILLI_OF_SECOND:e instanceof l.ChronoUnit?e.isTimeBased()||e===l.ChronoUnit.DAYS:null!=e&&e.isSupportedBy(this)}}],[{key:"now",value:function(){var e=arguments.length<=0||void 0===arguments[0]?c.Clock.systemUTC():arguments[0];return e.instant()}},{key:"from",value:function(e){try{var n=e.getLong(s.ChronoField.INSTANT_SECONDS),r=e.get(s.ChronoField.NANO_OF_SECOND);return t.ofEpochSecond(n,r)}catch(i){throw new f.DateTimeException("Unable to obtain Instant from TemporalAccessor: "+e+", type "+("undefined"==typeof e?"undefined":o(e)),i)}}},{key:"ofEpochSecond",value:function(e){var n=arguments.length<=1||void 0===arguments[1]?0:arguments[1],o=e+E.MathUtil.floorDiv(n,h.LocalTime.NANOS_PER_SECOND),r=E.MathUtil.floorMod(n,h.LocalTime.NANOS_PER_SECOND);return t._create(o,r)}},{key:"ofEpochMilli",value:function(e){var n=E.MathUtil.floorDiv(e,1e3),o=E.MathUtil.floorMod(e,1e3);return t._create(n,1e6*o)}},{key:"_create",value:function(e,n){return 0===e&&0===n?t.EPOCH:new t(e,n)}},{key:"validate",value:function(e,t){if(p>e||e>v)throw new f.DateTimeException("Instant exceeds minimum or maximum instant")}}]),t}(d.TemporalAccessor);_.EPOCH=new _(0,0),_.MIN=_.ofEpochSecond(p,0),_.MAX=_.ofEpochSecond(v,999999999)},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.ChronoUnit=void 0;var i=n(14),a=n(10),u=t.ChronoUnit=function(){function e(t,n){o(this,e),this._name=t,this._duration=n}return r(e,[{key:"duration",value:function(){return this._duration}},{key:"isDurationEstimated",value:function(){return this.isDateBased()||this===e.FOREVER}},{key:"isDateBased",value:function(){return this.compareTo(e.DAYS)>=0&&this!==e.FOREVER}},{key:"isTimeBased",value:function(){return this.compareTo(e.DAYS)<0}},{key:"isSupportedBy",value:function(t){if(this===e.FOREVER)return!1;try{return t.plus(1,this),!0}catch(n){try{return t.plus(-1,this),!0}catch(o){return!1}}}},{key:"addTo",value:function(e,t){return e.plus(t,this)}},{key:"between",value:function(e,t){return e.until(t,this)}},{key:"toString",value:function(){return this._name}},{key:"compareTo",value:function(e){return this.duration().compareTo(e.duration())}}]),e}();u.NANOS=new u("Nanos",i.Duration.ofNanos(1)),u.MICROS=new u("Micros",i.Duration.ofNanos(1e3)),u.MILLIS=new u("Millis",i.Duration.ofNanos(1e6)),u.SECONDS=new u("Seconds",i.Duration.ofSeconds(1)),u.MINUTES=new u("Minutes",i.Duration.ofSeconds(60)),u.HOURS=new u("Hours",i.Duration.ofSeconds(3600)),u.HALF_DAYS=new u("HalfDays",i.Duration.ofSeconds(43200)),u.DAYS=new u("Days",i.Duration.ofSeconds(86400)),u.WEEKS=new u("Weeks",i.Duration.ofSeconds(604800)),u.MONTHS=new u("Months",i.Duration.ofSeconds(2629746)),u.YEARS=new u("Years",i.Duration.ofSeconds(31556952)),u.DECADES=new u("Decades",i.Duration.ofSeconds(315569520)),u.CENTURIES=new u("Centuries",i.Duration.ofSeconds(3155695200)),u.MILLENNIA=new u("Millennia",i.Duration.ofSeconds(31556952e3)),u.ERAS=new u("Eras",i.Duration.ofSeconds(31556952*(a.Year.MAX_VALUE+1))),u.FOREVER=new u("Forever",i.Duration.ofSeconds(Number.MAX_SAFE_INTEGER,999999999))},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.Duration=void 0;var i=n(2),a=n(7),u=n(13),s=n(3),l=n(15),c=n(5),f=t.Duration=function(){function e(t,n){o(this,e),this._seconds=t,this._nanos=n}return r(e,[{key:"get",value:function(e){if(e===u.ChronoUnit.SECONDS)return this._seconds;if(e===u.ChronoUnit.NANOS)return this._nanos;throw new s.UnsupportedTemporalTypeException("Unsupported unit: "+e)}},{key:"units",value:function(){return[u.ChronoUnit.SECONDS,u.ChronoUnit.NANOS]}},{key:"isZero",value:function(){return 0==(this._seconds|this._nanos)}},{key:"isNegative",value:function(){return this._seconds<0}},{key:"seconds",value:function(){return this._seconds}},{key:"nano",value:function(){return this._nanos}},{key:"withSeconds",value:function(t){return e.create(t,this._nanos)}},{key:"withNanos",value:function(t){return a.ChronoField.NANO_OF_SECOND.checkValidIntValue(t),e.create(this._seconds,t)}},{key:"plusDuration",value:function(e){return this.plus(e.seconds(),e.nano())}},{key:"plus",value:function(t,n){return t instanceof e?((0,i.requireNonNull)(t,"duration"),this.plusDuration(t)):n instanceof u.ChronoUnit?((0,i.requireNonNull)(t,"amount"),(0,i.requireNonNull)(n,"unit"),this.plusAmountUnit(t,n)):((0,i.requireNonNull)(t,"seconds"),(0,i.requireNonNull)(n,"nanos"),this.plusSecondsNanos(t,n))}},{key:"plusAmountUnit",value:function(e,t){if((0,i.requireNonNull)(t,"unit"),t==u.ChronoUnit.DAYS)return this.plusSecondsNanos(c.MathUtil.safeMultiply(e,l.LocalTime.SECONDS_PER_DAY),0);if(t.isDurationEstimated())throw new s.UnsupportedTemporalTypeException("Unit must not have an estimated duration");if(0==e)return this;if(t instanceof u.ChronoUnit){switch(t){case u.ChronoUnit.NANOS:return this.plusNanos(e);case u.ChronoUnit.MICROS:return this.plusSecondsNanos(1e3*c.MathUtil.intDiv(e,1e9),1e3*c.MathUtil.intMod(e,1e9));case u.ChronoUnit.MILLIS:return this.plusMillis(e);case u.ChronoUnit.SECONDS:return this.plusSeconds(e)}return this.plusSecondsNanos(c.MathUtil.safeMultiply(t.duration().seconds(),e),0)}var n=t.duration().multipliedBy(e);return this.plusSecondsNanos(n.seconds(),n.nano())}},{key:"plusDays",value:function(e){return this.plusSecondsNanos(c.MathUtil.safeMultiply(e,l.LocalTime.SECONDS_PER_DAY),0)}},{key:"plusHours",value:function(e){return this.plusSecondsNanos(c.MathUtil.safeMultiply(e,l.LocalTime.SECONDS_PER_HOUR),0)}},{key:"plusMinutes",value:function(e){return this.plusSecondsNanos(c.MathUtil.safeMultiply(e,l.LocalTime.SECONDS_PER_MINUTE),0)}},{key:"plusSeconds",value:function(e){return this.plusSecondsNanos(e,0)}},{key:"plusMillis",value:function(e){return this.plusSecondsNanos(c.MathUtil.intDiv(e,1e3),1e6*c.MathUtil.intMod(e,1e3))}},{key:"plusNanos",value:function(e){return this.plusSecondsNanos(0,e)}},{key:"plusSecondsNanos",value:function(t,n){if(0==(t|n))return this;var o=c.MathUtil.safeAdd(this._seconds,t);o=c.MathUtil.safeAdd(o,c.MathUtil.intDiv(n,l.LocalTime.NANOS_PER_SECOND)),n=c.MathUtil.intMod(n,l.LocalTime.NANOS_PER_SECOND);var r=c.MathUtil.safeAdd(this._nanos,n);return e.ofSeconds(o,r)}},{key:"minus",value:function(t,n){return t instanceof e?((0,i.requireNonNull)(t,"duration"),this.minusDuration(t)):n instanceof u.ChronoUnit?((0,i.requireNonNull)(t,"amount"),(0,i.requireNonNull)(n,"unit"),this.minusAmountUnit(t,n)):((0,i.requireNonNull)(t,"seconds"),(0,i.requireNonNull)(n,"nanos"),this.minusSecondsNanos(t,n))}},{key:"minusDuration",value:function(e){var t=e.seconds(),n=e.nano();return t==c.MIN_SAFE_INTEGER?this.plus(c.MAX_SAFE_INTEGER,-n).plus(1,0):this.plus(-t,-n)}},{key:"minusAmountUnit",value:function(e,t){return e==c.MIN_SAFE_INTEGER?this.plusAmountUnit(c.MAX_SAFE_INTEGER,t).plus(1,t):this.plusAmountUnit(-e,t)}},{key:"minusDays",value:function(e){return e==c.MIN_SAFE_INTEGER?this.plusDays(c.MAX_SAFE_INTEGER).plusDays(1):this.plusDays(-e)}},{key:"minusHours",value:function(e){return e==c.MIN_SAFE_INTEGER?this.plusHours(c.MAX_SAFE_INTEGER).plusHours(1):this.plusHours(-e)}},{key:"minusMinutes",value:function(e){return e==c.MIN_SAFE_INTEGER?this.plusMinutes(c.MAX_SAFE_INTEGER).plusMinutes(1):this.plusMinutes(-e)}},{key:"minusSeconds",value:function(e){return e==c.MIN_SAFE_INTEGER?this.plusSeconds(c.MAX_SAFE_INTEGER).plusSeconds(1):this.plusSeconds(-e)}},{key:"minusMillis",value:function(e){return e==c.MIN_SAFE_INTEGER?this.plusMillis(c.MAX_SAFE_INTEGER).plusMillis(1):this.plusMillis(-e)}},{key:"minusNanos",value:function(e){return e==c.MIN_SAFE_INTEGER?this.plusNanos(c.MAX_SAFE_INTEGER).plusNanos(1):this.plusNanos(-e)}},{key:"multipliedBy",value:function(t){return 0==t?e.ZERO:1==t?this:e.create(c.MathUtil.safeMultiply(this.toSeconds(),t))}},{key:"dividedBy",value:function(t){if(0==t)throw new s.ArithmeticException("Cannot divide by zero");return 1==t?this:e.create(this.toSeconds()/t)}},{key:"toSeconds",value:function(){var e=c.MathUtil.safeMultiply(this._nanos,Math.pow(10,-9));return c.MathUtil.safeAdd(this._seconds,e)}},{key:"negated",value:function(){return this.multipliedBy(-1)}},{key:"abs",value:function(){return this.isNegative()?this.negated():this}},{key:"addTo",value:function(e){return 0!=this._seconds&&(e=e.plus(this._seconds,u.ChronoUnit.SECONDS)), | ||
0!=this._nanos&&(e=e.plus(this._nanos,u.ChronoUnit.NANOS)),e}},{key:"subtractFrom",value:function(e){return 0!=this._seconds&&(e=e.minus(this._seconds,u.ChronoUnit.SECONDS)),0!=this._nanos&&(e=e.minus(this._nanos,u.ChronoUnit.NANOS)),e}},{key:"toDays",value:function(){return this._seconds/l.LocalTime.SECONDS_PER_DAY}},{key:"toHours",value:function(){return this._seconds/l.LocalTime.SECONDS_PER_HOUR}},{key:"toMinutes",value:function(){return this._seconds/l.LocalTime.SECONDS_PER_MINUTE}},{key:"toMillis",value:function(){var e=Math.round(c.MathUtil.safeMultiply(this._seconds,1e3));return e=c.MathUtil.safeAdd(e,c.MathUtil.intDiv(this._nanos,1e6))}},{key:"toNanos",value:function(){var e=c.MathUtil.safeMultiply(this._seconds,l.LocalTime.NANOS_PER_SECOND);return e=c.MathUtil.safeAdd(e,this._nanos)}},{key:"compareTo",value:function(t){(0,i.requireNonNull)(t,"otherDuration"),(0,i.assert)(t instanceof e,"otherDuration must be a Duration");var n=c.MathUtil.compareNumbers(this._seconds,t.seconds());return 0!=n?n:this._nanos-t.nano()}},{key:"equals",value:function(t){return this===t?!0:t instanceof e?this.seconds()==t.seconds()&&this.nano()==t.nano():!1}},{key:"toString",value:function(){if(this===e.ZERO)return"PT0S";var t=c.MathUtil.intDiv(this._seconds,l.LocalTime.SECONDS_PER_HOUR),n=c.MathUtil.intDiv(c.MathUtil.intMod(this._seconds,l.LocalTime.SECONDS_PER_HOUR),l.LocalTime.SECONDS_PER_MINUTE),o=c.MathUtil.intMod(this._seconds,l.LocalTime.SECONDS_PER_MINUTE),r="PT";if(0!=t&&(r+=t+"H"),0!=n&&(r+=n+"M"),0==o&&0==this._nanos&&r.length>2)return r;if(r+=0>o&&this._nanos>0?-1==o?"-0":o+1:o,this._nanos>0){r+=".";var i=void 0;for(i=0>o?""+(2*l.LocalTime.NANOS_PER_SECOND-this._nanos):""+(l.LocalTime.NANOS_PER_SECOND+this._nanos),i=i.slice(1,i.length),r+=i;"0"==r.charAt(r.length-1);)r=r.slice(0,r.length-1)}return r+="S"}}],[{key:"ofDays",value:function(t){return e.create(c.MathUtil.safeMultiply(t,l.LocalTime.SECONDS_PER_DAY),0)}},{key:"ofHours",value:function(t){return e.create(c.MathUtil.safeMultiply(t,l.LocalTime.SECONDS_PER_HOUR),0)}},{key:"ofMinutes",value:function(t){return e.create(c.MathUtil.safeMultiply(t,l.LocalTime.SECONDS_PER_MINUTE),0)}},{key:"ofSeconds",value:function(t){var n=arguments.length<=1||void 0===arguments[1]?0:arguments[1],o=c.MathUtil.safeAdd(t,c.MathUtil.floorDiv(n,l.LocalTime.NANOS_PER_SECOND)),r=c.MathUtil.floorMod(n,l.LocalTime.NANOS_PER_SECOND);return e.create(o,r)}},{key:"ofMillis",value:function(t){var n=c.MathUtil.intDiv(t,1e3),o=c.MathUtil.intMod(t,1e3);return 0>o&&(o+=1e3,n--),e.create(n,1e6*o)}},{key:"ofNanos",value:function(e){var t=c.MathUtil.intDiv(e,l.LocalTime.NANOS_PER_SECOND),n=c.MathUtil.intMod(e,l.LocalTime.NANOS_PER_SECOND);return 0>n&&(n+=l.LocalTime.NANOS_PER_SECOND,t--),this.create(t,n)}},{key:"of",value:function(t,n){return e.ZERO.plus(t,n)}},{key:"from",value:function(t){(0,i.requireNonNull)(t,"amount");var n=e.ZERO;return t.units().forEach(function(e){n=n.plus(t.get(e),e)}),n}},{key:"between",value:function(e,t){(0,i.requireNonNull)(e,"startInclusive"),(0,i.requireNonNull)(t,"endExclusive");var n=e.until(t,u.ChronoUnit.SECONDS),o=0;if(e.isSupported(a.ChronoField.NANO_OF_SECOND)&&t.isSupported(a.ChronoField.NANO_OF_SECOND))try{var r=e.getLong(a.ChronoField.NANO_OF_SECOND);if(o=t.getLong(a.ChronoField.NANO_OF_SECOND)-r,n>0&&0>o)o+=l.LocalTime.NANOS_PER_SECOND;else if(0>n&&o>0)o-=l.LocalTime.NANOS_PER_SECOND;else if(0==n&&0!=o){var s=t["with"](a.ChronoField.NANO_OF_SECOND,r);n=e.until(s,u.ChronoUnit.SECONDS)}}catch(c){}return this.ofSeconds(n,o)}},{key:"parse",value:function(t){(0,i.requireNonNull)(t,"text");var n=new RegExp("([-+]?)P(?:([-+]?[0-9]+)D)?(T(?:([-+]?[0-9]+)H)?(?:([-+]?[0-9]+)M)?(?:([-+]?[0-9]+)(?:[.,]([0-9]{0,9}))?S)?)?","i"),o=n.exec(t);if(null!==o&&"T"===o[3]==0){var r="-"===o[1],a=o[2],u=o[4],c=o[5],f=o[6],h=o[7];if(null!=a||null!=u||null!=c||null!=f){var E=e._parseNumber(t,a,l.LocalTime.SECONDS_PER_DAY,"days"),d=e._parseNumber(t,u,l.LocalTime.SECONDS_PER_HOUR,"hours"),p=e._parseNumber(t,c,l.LocalTime.SECONDS_PER_MINUTE,"minutes"),v=e._parseNumber(t,f,1,"seconds"),y=null!=f&&"-"==f.charAt(0),_=e._parseFraction(t,h,y?-1:1);try{return e.create(r,E,d,p,v,_)}catch(m){throw new s.DateTimeParseException("Text cannot be parsed to a Duration: overflow",t,0,m)}}}throw new s.DateTimeParseException("Text cannot be parsed to a Duration",t,0)}},{key:"_parseNumber",value:function(e,t,n,o){if(null==t)return 0;try{"+"===t[0]&&(t=t.substring(1));var r=parseFloat(t);return c.MathUtil.safeMultiply(r,n)}catch(i){throw new s.DateTimeParseException("Text cannot be parsed to a Duration: "+o,e,0,i)}}},{key:"_parseFraction",value:function(e,t,n){if(null==t||0==t.length)return 0;try{return t=(t+"000000000").substring(0,9),parseFloat(t)*n}catch(o){throw new s.DateTimeParseException("Text cannot be parsed to a Duration: fraction",e,0,o)}}},{key:"create",value:function(){return 1==arguments.length?e.createSeconds(arguments[0]):2==arguments.length?e.createSecondsNanos(arguments[0],arguments[1]):e.createNegateDaysHoursMinutesSecondsNanos(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5])}},{key:"createNegateDaysHoursMinutesSecondsNanos",value:function(t,n,o,r,i,a){var u=c.MathUtil.safeAdd(n,c.MathUtil.safeAdd(o,c.MathUtil.safeAdd(r,i)));return t?e.ofSeconds(u,a).negated():e.ofSeconds(u,a)}},{key:"createSecondsNanos",value:function(){var t=arguments.length<=0||void 0===arguments[0]?0:arguments[0],n=arguments.length<=1||void 0===arguments[1]?0:arguments[1];return 0==(t|n)?e.ZERO:(t>=0?n+=t%1*l.LocalTime.NANOS_PER_SECOND:n-=t%1*l.LocalTime.NANOS_PER_SECOND,t=Math.floor(t),n=Math.round(n),new e(t,n))}},{key:"createSeconds",value:function(t){var n=Math.round(t*Math.pow(10,9)),o=c.MathUtil.intDiv(n,l.LocalTime.NANOS_PER_SECOND),r=c.MathUtil.intMod(n,l.LocalTime.NANOS_PER_SECOND);return e.ofSeconds(o,r)}}]),e}();f.ZERO=new f(0,0)},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=t.LocalTime=function r(){n(this,r)};o.HOURS_PER_DAY=24,o.MINUTES_PER_HOUR=60,o.MINUTES_PER_DAY=o.MINUTES_PER_HOUR*o.HOURS_PER_DAY,o.SECONDS_PER_MINUTE=60,o.SECONDS_PER_HOUR=o.SECONDS_PER_MINUTE*o.MINUTES_PER_HOUR,o.SECONDS_PER_DAY=o.SECONDS_PER_HOUR*o.HOURS_PER_DAY,o.NANOS_PER_SECOND=1e9},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.TemporalAccessor=void 0;var i=n(7),a=n(17),u=n(3),s=function(){function e(){o(this,e)}return r(e,[{key:"query",value:function(e){return e==a.TemporalQueries.zoneId()||e==a.TemporalQueries.chronology()||e==a.TemporalQueries.precision()?null:e.queryFrom(this)}},{key:"range",value:function(e){if(e instanceof i.ChronoField){if(this.isSupported(e))return e.range();throw new u.UnsupportedTemporalTypeException("Unsupported field: "+e)}return e.rangeRefinedBy(this)}}]),e}();t.TemporalAccessor=s},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){var t=function o(){n(this,o)};return t.prototype.queryFrom=e,new t}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0});var i=t.TemporalQueries=function(){function e(){n(this,e)}return r(e,null,[{key:"zoneId",value:function(){return e.ZONE_ID}},{key:"chronology",value:function(){return e.CHRONO}},{key:"precision",value:function(){return e.PRECISION}},{key:"zone",value:function(){return e.ZONE}},{key:"offset",value:function(){return e.OFFSET}},{key:"localDate",value:function(){return e.LOCAL_DATE}},{key:"localTime",value:function(){return e.LOCAL_TIME}}]),e}();i.ZONE_ID=o(function(e){return e.query(i.ZONE_ID)}),i.CHRONO=o(function(e){return e.query(i.CHRONO)}),i.PRECISION=o(function(e){return e.query(i.PRECISION)}),i.OFFSET=o(function(e){return e.isSupported(i.OFFSET_SECONDS)?ZoneOffset.ofTotalSeconds(e.get(i.OFFSET_SECONDS)):null}),i.ZONE=o(function(e){var t=e.query(i.ZONE_ID);return null!=t?t:e.query(i.OFFSET)}),i.LOCAL_DATE=o(function(e){return e.isSupported(i.EPOCH_DAY)?LocalDate.ofEpochDay(e.getLong(i.EPOCH_DAY)):null}),i.LOCAL_TIME=o(function(e){return e.isSupported(i.NANO_OF_DAY)?LocalTime.ofNanoOfDay(e.getLong(i.NANO_OF_DAY)):null})},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.ZoneOffset=void 0;var i=n(3),a=n(15),u=18*a.LocalTime.SECONDS_PER_HOUR,s={},l=t.ZoneOffset=function(){function e(t){o(this,e),e.validateTotalSeconds(t),this._totalSeconds=t}return r(e,[{key:"totalSeconds",value:function(){return this._totalSeconds}},{key:"equals",value:function(t){return this===t?!0:t instanceof e?this._totalSeconds===t._totalSeconds:!1}}],[{key:"validateTotalSeconds",value:function(e){if(Math.abs(e)>u)throw new i.DateTimeException("Zone offset not in valid range: -18:00 to +18:00")}},{key:"validate",value:function(e,t,n){if(-18>e||e>18)throw new i.DateTimeException("Zone offset hours not in valid range: value "+e+" is not in the range -18 to 18");if(e>0){if(0>t||0>n)throw new i.DateTimeException("Zone offset minutes and seconds must be positive because hours is positive")}else if(0>e){if(t>0||n>0)throw new i.DateTimeException("Zone offset minutes and seconds must be negative because hours is negative")}else if(t>0&&0>n||0>t&&n>0)throw new i.DateTimeException("Zone offset minutes and seconds must have the same sign");if(Math.abs(t)>59)throw new i.DateTimeException("Zone offset minutes not in valid range: abs(value) "+Math.abs(t)+" is not in the range 0 to 59");if(Math.abs(n)>59)throw new i.DateTimeException("Zone offset seconds not in valid range: abs(value) "+Math.abs(n)+" is not in the range 0 to 59");if(18==Math.abs(e)&&(Math.abs(t)>0||Math.abs(n)>0))throw new i.DateTimeException("Zone offset not in valid range: -18:00 to +18:00")}},{key:"ofHours",value:function(t){return e.ofHoursMinutesSeconds(t,0,0)}},{key:"ofHoursMinutes",value:function(t,n){return e.ofHoursMinutesSeconds(t,n,0)}},{key:"ofHoursMinutesSeconds",value:function(t,n,o){e.validate(t,n,o);var r=t*a.LocalTime.SECONDS_PER_HOUR+n*a.LocalTime.SECONDS_PER_MINUTE+o;return e.ofTotalSeconds(r)}},{key:"ofTotalMinutes",value:function(t){var n=t*a.LocalTime.SECONDS_PER_MINUTE;return e.ofTotalSeconds(n)}},{key:"ofTotalSeconds",value:function(t){if(t%(15*a.LocalTime.SECONDS_PER_MINUTE)===0){var n=t,o=s[n];return null==o&&(o=new e(t),s[n]=o),o}return new e(t)}}]),e}();l.UTC=l.ofTotalSeconds(0),l.MIN=l.ofTotalSeconds(-u),l.MAX=l.ofTotalSeconds(u)},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=function y(e,t,n){null===e&&(e=Function.prototype);var o=Object.getOwnPropertyDescriptor(e,t);if(void 0===o){var r=Object.getPrototypeOf(e);return null===r?void 0:y(r,t,n)}if("value"in o)return o.value;var i=o.get;if(void 0!==i)return i.call(n)};Object.defineProperty(t,"__esModule",{value:!0}),t.Month=void 0;var s=n(2),l=n(7),c=n(13),f=n(3),h=n(6),E=n(16),d=n(17),p=function(e){function t(e){o(this,t);var n=r(this,Object.getPrototypeOf(t).call(this));return n._value=e,n}return i(t,e),a(t,[{key:"value",value:function(){return this._value}},{key:"isSupported",value:function(e){return null===e?!1:e instanceof l.ChronoField?e===l.ChronoField.MONTH_OF_YEAR:null!=e&&e.isSupportedBy(this)}},{key:"get",value:function(e){return e===l.ChronoField.MONTH_OF_YEAR?this.value():range(e).checkValidIntValue(getLong(e),e)}},{key:"getLong",value:function(e){if(e===l.ChronoField.MONTH_OF_YEAR)return this.value();if(e instanceof l.ChronoField)throw new f.UnsupportedTemporalTypeException("Unsupported field: "+e);return e.getFrom(this)}},{key:"plus",value:function(e){var n=Math.floor(e%12)+12,o=(this.value()+n)%12;return o=0==o?12:o,t.of(o)}},{key:"minus",value:function(e){return this.plus(-(e%12))}},{key:"length",value:function(e){switch(this){case t.FEBRUARY:return e?29:28;case t.APRIL:case t.JUNE:case t.SEPTEMBER:case t.NOVEMBER:return 30;default:return 31}}},{key:"minLength",value:function(){switch(this){case t.FEBRUARY:return 28;case t.APRIL:case t.JUNE:case t.SEPTEMBER:case t.NOVEMBER:return 30;default:return 31}}},{key:"maxLength",value:function(){switch(this){case t.FEBRUARY:return 29;case t.APRIL:case t.JUNE:case t.SEPTEMBER:case t.NOVEMBER:return 30;default:return 31}}},{key:"firstDayOfYear",value:function(e){var n=e?1:0;switch(this){case t.JANUARY:return 1;case t.FEBRUARY:return 32;case t.MARCH:return 60+n;case t.APRIL:return 91+n;case t.MAY:return 121+n;case t.JUNE:return 152+n;case t.JULY:return 182+n;case t.AUGUST:return 213+n;case t.SEPTEMBER:return 244+n;case t.OCTOBER:return 274+n;case t.NOVEMBER:return 305+n;case t.DECEMBER:default:return 335+n}}},{key:"firstMonthOfQuarter",value:function(){switch(this){case t.JANUARY:case t.FEBRUARY:case t.MARCH:return t.JANUARY;case t.APRIL:case t.MAY:case t.JUNE:return t.APRIL;case t.JULY:case t.AUGUST:case t.SEPTEMBER:return t.JULY;case t.OCTOBER:case t.NOVEMBER:case t.DECEMBER:default:return t.OCTOBER}}},{key:"query",value:function(e){return(0,s.assert)(null!=e,"query() parameter must not be null",f.DateTimeException),e===d.TemporalQueries.chronology()?h.IsoChronology.INSTANCE:e===d.TemporalQueries.precision()?c.ChronoUnit.MONTHS:u(Object.getPrototypeOf(t.prototype),"query",this).call(this,e)}},{key:"toString",value:function(e){switch(this){case t.JANUARY:return"JANUARY";case t.FEBRUARY:return"FEBRUARY";case t.MARCH:return"MARCH";case t.APRIL:return"APRIL";case t.MAY:return"MAY";case t.JUNE:return"JUNE";case t.JULY:return"JULY";case t.AUGUST:return"AUGUST";case t.SEPTEMBER:return"SEPTEMBER";case t.OCTOBER:return"OCTOBER";case t.NOVEMBER:return"NOVEMBER";case t.DECEMBER:return"DECEMBER";default:return"unknown Month, value: "+this.value()}}}],[{key:"of",value:function(e){return(1>e||e>12)&&(0,s.assert)(!1,"Invalid value for MonthOfYear: "+e,f.DateTimeException),v[e-1]}}]),t}(E.TemporalAccessor);t.Month=p,p.JANUARY=new p(1),p.FEBRUARY=new p(2),p.MARCH=new p(3),p.APRIL=new p(4),p.MAY=new p(5),p.JUNE=new p(6),p.JULY=new p(7),p.AUGUST=new p(8),p.SEPTEMBER=new p(9),p.OCTOBER=new p(10),p.NOVEMBER=new p(11),p.DECEMBER=new p(12);var v=[p.JANUARY,p.FEBRUARY,p.MARCH,p.APRIL,p.MAY,p.JUNE,p.JULY,p.AUGUST,p.SEPTEMBER,p.OCTOBER,p.NOVEMBER,p.DECEMBER]}]); |
{ | ||
"name": "js-joda", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "a date and time library for javascript", | ||
@@ -12,6 +12,6 @@ "repository": { | ||
"prepublish": "npm run build-dist", | ||
"test": "./node_modules/.bin/mocha --compilers js:babel/register ./test/*Test.js ./test/**/*Test.js", | ||
"test": "./node_modules/.bin/mocha --compilers js:babel-core/register ./test/*Test.js ./test/**/*Test.js", | ||
"test-coverage": "COVERAGE=1 ./node_modules/.bin/babel-node ./node_modules/.bin/isparta cover ./node_modules/.bin/_mocha -- ./test/*Test.js ./test/**/*Test.js", | ||
"test-browser": "./node_modules/.bin/karma start --single-run", | ||
"test-ci": "npm run test && npm run test-browser -- --browsers \"Firefox\" && npm run build-esdoc && npm run test-coverage", | ||
"test-ci": "npm run build-dist && npm run test && npm run test-browser -- --browsers \"Firefox,PhantomJS\" && npm run build-esdoc && npm run test-coverage", | ||
"build-esdoc": " ./node_modules/.bin/esdoc -c esdoc.json", | ||
@@ -29,9 +29,11 @@ "build-dist": "./node_modules/.bin/webpack --progress --colors --bail && DIST_MIN=1 ./node_modules/.bin/webpack --progress --colors --bail", | ||
"devDependencies": { | ||
"babel": "^5.8.23", | ||
"babel-core": "^5.8.25", | ||
"babel-loader": "^5.3.2", | ||
"babel": "^6.3.26", | ||
"babel-cli": "^6.3.17", | ||
"babel-core": "^6.3.26", | ||
"babel-loader": "^6.2.0", | ||
"babel-preset-es2015": "^6.3.13", | ||
"chai": "^3.3.0", | ||
"coveralls": "^2.11.4", | ||
"esdoc": "^0.4.0", | ||
"isparta": "^3.1.0", | ||
"isparta": "^4.0.0", | ||
"karma": "^0.13.11", | ||
@@ -42,2 +44,3 @@ "karma-chai-plugins": "^0.6.0", | ||
"karma-mocha": "^0.2.0", | ||
"karma-phantomjs-launcher": "^0.2.2", | ||
"karma-sourcemap-loader": "^0.3.6", | ||
@@ -47,4 +50,9 @@ "karma-webpack": "^1.7.0", | ||
"mocha": "^2.3.3", | ||
"phantomjs": "^1.9.19", | ||
"webpack": "^1.12.2" | ||
} | ||
}, | ||
"dependencies": { | ||
"es6-error": "^2.0.2" | ||
}, | ||
"license": "BSD-3-Clause" | ||
} |
@@ -10,18 +10,24 @@ Immutable data and time library for javascript | ||
**js-joda is a project that wants to bring joda time library to the javascript world. | ||
**js-joda is a project that wants to bring JSR-310 (more specifically the ThreeTen-Backport) date and time API to the javascript world. | ||
The Project is in a very early state. | ||
Be aware that the most of the things written here are not ready yet** | ||
js-joda, a port of the Joda-Time immutable data and time library to javascript. | ||
js-joda, a port of the ThreeTen immutable data and time library to javascript. | ||
It provides a simple and clean API based on the ISO8601 calendar. | ||
Joda-Time is the de facto standard date and time library for Java. From Java SE 8 it is part of the jdk at java.time (JSR-310). | ||
Joda-Time (the predecessor project) used to be the de facto standard date and time library for Java. It is the base for JSR-310 that became part of Java SE 8 in the java.time package. | ||
JSR-310 is a new implementation with an API 'inspired by Joda-Time' but improvements on some design flaws (see http://blog.joda.org/2009/11/why-jsr-310-isn-joda-time_4941.html) | ||
js-joda is using the ThreeTen-Backport implementation (http://www.threeten.org/threetenbp/) as a reference base for implementation. | ||
This allows us to release js-joda under the BSD License while the OpenJDK java.time implementation is under GNU GPL+linking exception. | ||
The API of the ThreeTen-Backport is mostly identical to the official Java SE 8 API from the view of our javascript port. | ||
## Why yet another javascript date and time library | ||
+ Popular javascript date libraries like moment or date-utils are wrappers around the native javascript Date object, | ||
providing syntactic sugar. The native Date object always consist of a date, time and a timezone part. | ||
providing syntactic sugar. The native Date object always consist of a date, time and a timezone part. | ||
In opposite to that, js-joda is a standalone date and time implementation. | ||
+ In opposite to that, js-joda is a standalone date and time implementation. | ||
It brings concepts like a LocalDate that allows to handle dates like birthdays or holidays in a clean and error-safe way, | ||
especially if this dates are persisted to an external server. | ||
+ The API has a domain-driven design with classes for the different use cases, like LocalDate, ZonedDateTime or Period. | ||
For examples LocalDate allows to handle dates like birthdays or holidays in a clean and error-safe way, | ||
especially if these dates are persisted to an external server. | ||
@@ -31,3 +37,3 @@ + js-joda is immutable. Immutability aligns well with pure functions and | ||
+ js-joda is a port of the sophisticated, robust and domain-driven API of Joda-Time (to be more precise of the jdk8 java.time package). | ||
+ js-joda is a port of the sophisticated, robust and domain-driven API of Joda-Time (to be more precise of the ThreeTen-Backport of the Java SE 8 java.time package). | ||
@@ -70,12 +76,25 @@ ## Getting started | ||
## Roadmap | ||
### Milestone 1 | ||
Our current plan is to have a first milestone with LocalDate, LocalDateTime, Instant, Duration and Period working. | ||
The result of the first milestone will be a fully functional Date/Time library, converting from and to ISO8601, with UTC and system default timezone. | ||
### Future Milestones | ||
Any further timezone converting and localization is not part of the first milestone and will be saved for later. This might also be an extra package | ||
to reduce library size if Timezone functionality is not needed. | ||
## License | ||
+ The License model is still under consideration, but it will be an open source license. | ||
+ js-joda is released under the [BSD 3-clause license](LICENSE.md): | ||
+ our implementation reference base ThreeTen-Backport (http://www.threeten.org/threetenbp/) is also released under the BSD 3-clause license | ||
+ Joda-Time is under Apache 2.0 licence. | ||
+ OpenJdk is under GNU GPL+linking exception. | ||
+ OpenJDK is under GNU GPL+linking exception. | ||
+ The author of joda time and the lead architect of the JSR-310 is Stephen Colebourne. | ||
The API of this project (as far as possible with javascript), a lot of implementation details and documentation | ||
@@ -82,0 +101,0 @@ are just copied but never equalled ;) |
@@ -1,5 +0,18 @@ | ||
export function assert(assertion, msg) { | ||
import {NullPointerException} from './errors'; | ||
export function assert(assertion, msg, error) { | ||
if(!assertion){ | ||
throw new Error(msg); | ||
if (error) { | ||
throw new error(msg); | ||
} else { | ||
throw new Error(msg); | ||
} | ||
} | ||
} | ||
export function requireNonNull(value, parameterName) { | ||
if (value == null) { | ||
throw new NullPointerException(parameterName + ' must not be null'); | ||
} | ||
return value; | ||
} |
@@ -26,1 +26,3 @@ export class IsoChronology { | ||
IsoChronology.INSTANCE = new IsoChronology(); | ||
@@ -1,5 +0,5 @@ | ||
import { LocalDate } from './LocalDate' | ||
export { LocalDate } from './LocalDate'; | ||
export { Instant } from './Instant'; | ||
export { Clock } from './Clock'; | ||
export { ZoneOffset } from './ZoneOffset'; | ||
export default { | ||
LocalDate: LocalDate | ||
} |
import {assert} from './assert'; | ||
import { MathUtil } from './MathUtil'; | ||
import {DateTimeException} from './errors'; | ||
import { IsoChronology } from './chrono/IsoChronology'; | ||
import {DAY_OF_MONTH, MONTH_OF_YEAR, YEAR } from './temporal/ChronoField'; | ||
import {ChronoField} from './temporal/ChronoField'; | ||
import {Clock} from './Clock'; | ||
import {Month} from './Month'; | ||
import {Year} from './Year'; | ||
import {LocalTime} from './LocalTime'; | ||
@@ -41,6 +47,9 @@ /** | ||
* @param {number} year | ||
* @param {number} month | ||
* @param {Month, number} month | ||
* @param {number} dayOfMonth | ||
*/ | ||
constructor(year, month, dayOfMonth){ | ||
if (month instanceof Month) { | ||
month = month.value(); | ||
} | ||
LocalDate.validate(year, month, dayOfMonth); | ||
@@ -53,7 +62,24 @@ this._year = year; | ||
/** | ||
* Obtains an instance of {@code LocalDate} from a year, month and day. | ||
* <p> | ||
* This returns a {@code LocalDate} with the specified year, month and day-of-month. | ||
* The day must be valid for the year and month, otherwise an exception will be thrown. | ||
* | ||
* @param {number} year the year to represent, from MIN_YEAR to MAX_YEAR | ||
* @param {Month, number} month the month-of-year to represent, from 1 (January) to 12 (December) | ||
* @param {number} dayOfMonth the day-of-month to represent, from 1 to 31 | ||
* @return LocalDate the local date, not null | ||
* @throws DateTimeException if the value of any field is out of range, | ||
* or if the day-of-month is invalid for the month-year | ||
*/ | ||
static of(year, month, dayOfMonth) { | ||
return new LocalDate(year, month, dayOfMonth); | ||
} | ||
/** | ||
* | ||
* @return {number} gets the year | ||
*/ | ||
year() { | ||
return this._year | ||
return this._year; | ||
} | ||
@@ -65,4 +91,8 @@ | ||
*/ | ||
monthValue() { | ||
return this._month; | ||
} | ||
month() { | ||
return this._month | ||
return Month.of(this._month); | ||
} | ||
@@ -74,7 +104,7 @@ | ||
*/ | ||
day() { | ||
return this._day | ||
dayOfMonth() { | ||
return this._day; | ||
} | ||
/* | ||
/** | ||
* Returns a copy of this LocalDate with the specified number of days added. | ||
@@ -100,4 +130,23 @@ * | ||
return LocalDate.ofEpochDay(mjDay); | ||
}; | ||
} | ||
/* | ||
* Returns a copy of this LocalDate with the specified number of days subtracted. | ||
* | ||
* This method subtracts the specified amount from the days field decrementing the | ||
* month and year fields as necessary to ensure the result remains valid. | ||
* The result is only invalid if the maximum/minimum year is exceeded. | ||
* | ||
* For example, 2009-01-01 minus one day would result in 2008-12-31. | ||
* | ||
* This instance is immutable and unaffected by this method call. | ||
* | ||
* @param {number} daysToSubtract - the days to subtract, may be negative | ||
* @return {LocalDate} a LocalDate based on this date with the days subtracted, not null | ||
* @throws AssertionError if the result exceeds the supported date range | ||
*/ | ||
minusDays(daysToSubtract) { | ||
return this.plusDays(daysToSubtract * -1); | ||
} | ||
/** | ||
@@ -113,12 +162,12 @@ * Converts this date to the Epoch Day. | ||
var y = this.year(); | ||
var m = this.month(); | ||
var m = this.monthValue(); | ||
var total = 0; | ||
total += 365 * y; | ||
if (y >= 0) { | ||
total += MathUtil.div(y + 3, 4) - MathUtil.div(y + 99, 100) + MathUtil.div(y + 399, 400); | ||
total += MathUtil.intDiv(y + 3, 4) - MathUtil.intDiv(y + 99, 100) + MathUtil.intDiv(y + 399, 400); | ||
} else { | ||
total -= MathUtil.div(y, -4) - MathUtil.div(y, -100) + MathUtil.div(y, -400); | ||
total -= MathUtil.intDiv(y, -4) - MathUtil.intDiv(y, -100) + MathUtil.intDiv(y, -400); | ||
} | ||
total += MathUtil.div(367 * m - 362, 12); | ||
total += this.day() - 1; | ||
total += MathUtil.intDiv(367 * m - 362, 12); | ||
total += this.dayOfMonth() - 1; | ||
if (m > 2) { | ||
@@ -134,2 +183,51 @@ total--; | ||
/** | ||
* Obtains the current date from the system clock in the default time-zone or | ||
* if specified, the current date from the specified clock. | ||
* | ||
* This will query the specified clock to obtain the current date - today. | ||
* Using this method allows the use of an alternate clock for testing. | ||
* | ||
* @param clock the clock to use, if null, the system clock and default time-zone is used. | ||
* @return the current date, not null | ||
*/ | ||
static now(clock = Clock.systemDefaultZone()) { | ||
var now = clock.instant(); | ||
var offset = clock.offset(now); | ||
var epochSec = now.epochSecond() + offset.totalSeconds(); | ||
var epochDay = MathUtil.floorDiv(epochSec, LocalTime.SECONDS_PER_DAY); | ||
return LocalDate.ofEpochDay(epochDay); | ||
} | ||
/** | ||
* Checks if this date is equal to another date. | ||
* | ||
* Compares this LocalDate with another ensuring that the date is the same. | ||
* | ||
* Only objects of type LocalDate are compared, other types return false. | ||
* | ||
* @param otherDate the object to check, null returns false | ||
* @return true if this is equal to the other date | ||
*/ | ||
equals(otherDate) { | ||
if (this === otherDate) { | ||
return true; | ||
} | ||
if (otherDate instanceof LocalDate) { | ||
return this._compareTo(otherDate) === 0; | ||
} | ||
return false; | ||
} | ||
_compareTo(otherDate){ | ||
var cmp = this.year() - otherDate.year(); | ||
if (cmp === 0) { | ||
cmp = (this.monthValue() - otherDate.monthValue()); | ||
if (cmp === 0) { | ||
cmp = (this.dayOfMonth() - otherDate.dayOfMonth()); | ||
} | ||
} | ||
return cmp; | ||
} | ||
/** | ||
* Outputs this date as a String, such as 2007-12-03. | ||
@@ -144,4 +242,4 @@ * The output will be in the ISO-8601 format uuuu-MM-dd. | ||
var yearValue = this.year(); | ||
var monthValue = this.month(); | ||
var dayValue = this.day(); | ||
var monthValue = this.monthValue(); | ||
var dayValue = this.dayOfMonth(); | ||
@@ -151,25 +249,25 @@ var absYear = Math.abs(yearValue); | ||
if (absYear < 1000) { | ||
if (yearValue < 0) { | ||
yearString = "-" + ("" + (yearValue - 10000)).slice(-4); | ||
} else { | ||
yearString = ("" + (yearValue + 10000)).slice(-4); | ||
} | ||
if (yearValue < 0) { | ||
yearString = '-' + ('' + (yearValue - 10000)).slice(-4); | ||
} else { | ||
yearString = ('' + (yearValue + 10000)).slice(-4); | ||
} | ||
} else { | ||
if (yearValue > 9999) { | ||
yearString = "+" + yearValue; | ||
} else { | ||
yearString = "" + yearValue; | ||
} | ||
if (yearValue > 9999) { | ||
yearString = '+' + yearValue; | ||
} else { | ||
yearString = '' + yearValue; | ||
} | ||
} | ||
if (monthValue < 10) { | ||
monthString = "-0" + monthValue; | ||
monthString = '-0' + monthValue; | ||
} else { | ||
monthString = "-" + monthValue; | ||
monthString = '-' + monthValue; | ||
} | ||
if (dayValue < 10) { | ||
dayString = "-0" + dayValue; | ||
dayString = '-0' + dayValue; | ||
} else { | ||
dayString = "-" + dayValue; | ||
dayString = '-' + dayValue; | ||
} | ||
@@ -180,3 +278,3 @@ | ||
/* | ||
/** | ||
* Obtains an instance of LocalDate from the epoch day count. | ||
@@ -199,21 +297,86 @@ * | ||
if (zeroDay < 0) { | ||
adjustCycles = MathUtil.div(zeroDay + 1, DAYS_PER_CYCLE) - 1; | ||
adjustCycles = MathUtil.intDiv(zeroDay + 1, DAYS_PER_CYCLE) - 1; | ||
adjust = adjustCycles * 400; | ||
zeroDay += -adjustCycles * DAYS_PER_CYCLE; | ||
} | ||
yearEst = MathUtil.div(400 * zeroDay + 591, DAYS_PER_CYCLE); | ||
doyEst = zeroDay - (365 * yearEst + MathUtil.div(yearEst, 4) - MathUtil.div(yearEst, 100) + MathUtil.div(yearEst, 400)); | ||
yearEst = MathUtil.intDiv(400 * zeroDay + 591, DAYS_PER_CYCLE); | ||
doyEst = zeroDay - (365 * yearEst + MathUtil.intDiv(yearEst, 4) - MathUtil.intDiv(yearEst, 100) + MathUtil.intDiv(yearEst, 400)); | ||
if (doyEst < 0) { | ||
yearEst--; | ||
doyEst = zeroDay - (365 * yearEst + MathUtil.div(yearEst, 4) - MathUtil.div(yearEst, 100) + MathUtil.div(yearEst, 400)); | ||
doyEst = zeroDay - (365 * yearEst + MathUtil.intDiv(yearEst, 4) - MathUtil.intDiv(yearEst, 100) + MathUtil.intDiv(yearEst, 400)); | ||
} | ||
yearEst += adjust; | ||
marchDoy0 = doyEst; | ||
marchMonth0 = MathUtil.div(marchDoy0 * 5 + 2, 153); | ||
marchMonth0 = MathUtil.intDiv(marchDoy0 * 5 + 2, 153); | ||
month = (marchMonth0 + 2) % 12 + 1; | ||
dom = marchDoy0 - MathUtil.div(marchMonth0 * 306 + 5, 10) + 1; | ||
yearEst += MathUtil.div(marchMonth0, 10); | ||
dom = marchDoy0 - MathUtil.intDiv(marchMonth0 * 306 + 5, 10) + 1; | ||
yearEst += MathUtil.intDiv(marchMonth0, 10); | ||
year = yearEst; | ||
return new LocalDate(year, month, dom); | ||
}; | ||
} | ||
/** | ||
* Obtains an instance of {@code LocalDate} from a year and day-of-year. | ||
* <p> | ||
* This returns a {@code LocalDate} with the specified year and day-of-year. | ||
* The day-of-year must be valid for the year, otherwise an exception will be thrown. | ||
* | ||
* @param {number} year the year to represent, from MIN_YEAR to MAX_YEAR | ||
* @param {number} dayOfYear the day-of-year to represent, from 1 to 366 | ||
* @return LocalDate the local date, not null | ||
* @throws DateTimeException if the value of any field is out of range, | ||
* or if the day-of-year is invalid for the year | ||
*/ | ||
static ofYearDay(year, dayOfYear) { | ||
ChronoField.YEAR.checkValidValue(year); | ||
//TODO: ChronoField.DAY_OF_YEAR.checkValidValue(dayOfYear); | ||
var leap = IsoChronology.isLeapYear(year); | ||
if (dayOfYear === 366 && leap === false) { | ||
assert(false, 'Invalid date \'DayOfYear 366\' as \'' + year + '\' is not a leap year', DateTimeException); | ||
} | ||
var moy = Month.of(Math.floor((dayOfYear - 1) / 31 + 1)); | ||
var monthEnd = moy.firstDayOfYear(leap) + moy.length(leap) - 1; | ||
if (dayOfYear > monthEnd) { | ||
moy = moy.plus(1); | ||
} | ||
var dom = dayOfYear - moy.firstDayOfYear(leap) + 1; | ||
return new LocalDate(year, moy.value(), dom); | ||
} | ||
/** | ||
* Returns a copy of this {@code LocalDate} with the day-of-month altered. | ||
* <p> | ||
* If the resulting date is invalid, an exception is thrown. | ||
* <p> | ||
* This instance is immutable and unaffected by this method call. | ||
* | ||
* @param {number} dayOfMonth the day-of-month to set in the result, from 1 to 28-31 | ||
* @return {LocalDate} based on this date with the requested day, not null | ||
* @throws DateTimeException if the day-of-month value is invalid, | ||
* or if the day-of-month is invalid for the month-year | ||
*/ | ||
withDayOfMonth(dayOfMonth) { | ||
if (this._day === dayOfMonth) { | ||
return this; | ||
} | ||
return LocalDate.of(this._year, this._month, dayOfMonth); | ||
} | ||
/** | ||
* Returns a copy of this {@code LocalDate} with the month-of-year altered. | ||
* <p> | ||
* If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. | ||
* <p> | ||
* This instance is immutable and unaffected by this method call. | ||
* | ||
* @param {number} month the month-of-year to set in the result, from 1 (January) to 12 (December) | ||
* @return {@code LocalDate} based on this date with the requested month, not null | ||
* @throws DateTimeException if the month-of-year value is invalid | ||
*/ | ||
withMonth(month) { | ||
if (this._month === month) { | ||
return this; | ||
} | ||
return LocalDate.of(this._year, month, this._day); | ||
} | ||
@@ -225,5 +388,5 @@ /** | ||
var dom; | ||
YEAR.checkValidValue(year); | ||
MONTH_OF_YEAR.checkValidValue(month); | ||
DAY_OF_MONTH.checkValidValue(dayOfMonth); | ||
ChronoField.YEAR.checkValidValue(year); | ||
ChronoField.MONTH_OF_YEAR.checkValidValue(month); | ||
ChronoField.DAY_OF_MONTH.checkValidValue(dayOfMonth); | ||
if (dayOfMonth > 28) { | ||
@@ -243,9 +406,21 @@ dom = 31; | ||
if (dayOfMonth === 29) { | ||
assert(false, "Invalid date 'February 29' as '" + year + "' is not a leap year"); | ||
assert(false, 'Invalid date \'February 29\' as \'' + year + '\' is not a leap year', DateTimeException); | ||
} else { | ||
assert(false, "Invalid date '" + year + "' '" + month + "' '" + dayOfMonth + "'"); | ||
assert(false, 'Invalid date \'' + year + '\' \'' + month + '\' \'' + dayOfMonth + '\'', DateTimeException); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
} | ||
/** | ||
* The minimum supported {@code LocalDate} | ||
* This could be used by an application as a "far past" date. | ||
*/ | ||
LocalDate.MIN = LocalDate.of(Year.MIN_VALUE, 1, 1); | ||
/** | ||
* The maximum supported {@code LocalDate} | ||
* This could be used by an application as a "far future" date. | ||
*/ | ||
LocalDate.MAX = LocalDate.of(Year.MAX_VALUE, 12, 31); |
@@ -0,1 +1,6 @@ | ||
import {ArithmeticException} from './errors'; | ||
export const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : Math.pow(2, 53) - 1; // Number.MAX_SAFE_INTEGER not defined in #@#$%! PhantomJS | ||
export const MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER ? Number.MIN_SAFE_INTEGER : -(Math.pow(2, 53) - 1); // Number.MIN_SAFE_INTEGER not defined in #@#$%! PhantomJS | ||
/** | ||
@@ -5,6 +10,125 @@ * Math helper with static function for integer operations | ||
export class MathUtil { | ||
static div(a, b) { | ||
return ~~(a / b); | ||
static intDiv(x, y) { | ||
var r = x/y; | ||
if(r < 0){ | ||
return Math.ceil(r); | ||
} else { | ||
return Math.floor(r); | ||
} | ||
} | ||
static intMod(x, y) { | ||
var r = x - MathUtil.intDiv(x, y) * y; | ||
if(r < 0){ | ||
return Math.ceil(r); | ||
} else { | ||
return Math.floor(r); | ||
} | ||
} | ||
static floorDiv(x, y){ | ||
var r = Math.floor(x / y); | ||
return r; | ||
} | ||
static floorMod(x, y){ | ||
var r = x - MathUtil.floorDiv(x, y) * y; | ||
return r; | ||
} | ||
static safeAdd(x, y) { | ||
if (x === 0) { | ||
let r = y; | ||
if (r > MAX_SAFE_INTEGER || r < MIN_SAFE_INTEGER) { | ||
throw new ArithmeticException('Invalid addition beyond MAX_SAFE_INTEGER!'); | ||
} | ||
return r; | ||
} | ||
if (y === 0) { | ||
let r = x; | ||
if (r > MAX_SAFE_INTEGER || r < MIN_SAFE_INTEGER) { | ||
throw new ArithmeticException('Invalid addition beyond MAX_SAFE_INTEGER!'); | ||
} | ||
return r; | ||
} | ||
if (x === undefined || y === undefined) { | ||
throw new ArithmeticException('Invalid addition using undefined as argument'); | ||
} | ||
if (isNaN(x) || isNaN(y)) { | ||
throw new ArithmeticException('Invalid addition using NaN as argument'); | ||
} | ||
let r = x + y; | ||
// detect overflow, since neither x nor y are 0 (checked above) r cannot be === x or === y | ||
// TODO: is this correct and complete? | ||
if (r > MAX_SAFE_INTEGER || r < MIN_SAFE_INTEGER || r === x || r === y) { | ||
throw new ArithmeticException('Invalid addition beyond MAX_SAFE_INTEGER!'); | ||
} | ||
return r; | ||
} | ||
static safeSubtract(x, y) { | ||
if (x === 0) { | ||
let r = y; | ||
if (r > MAX_SAFE_INTEGER || r < MIN_SAFE_INTEGER) { | ||
throw new ArithmeticException('Invalid addition beyond MAX_SAFE_INTEGER!'); | ||
} | ||
return r; | ||
} | ||
if (y === 0) { | ||
let r = x; | ||
if (r > MAX_SAFE_INTEGER || r < MIN_SAFE_INTEGER) { | ||
throw new ArithmeticException('Invalid addition beyond MAX_SAFE_INTEGER!'); | ||
} | ||
return r; | ||
} | ||
if (x === undefined || y === undefined) { | ||
throw new ArithmeticException('Invalid subtraction using undefined as argument'); | ||
} | ||
if (isNaN(x) || isNaN(y)) { | ||
throw new ArithmeticException('Invalid subtraction using NaN as argument'); | ||
} | ||
let r = x - y; | ||
// detect overflow, since neither x nor y are 0 (checked above) r cannot be === x or === y | ||
// TODO: is this correct and complete? | ||
if (r < MIN_SAFE_INTEGER || r > MAX_SAFE_INTEGER || r === x || r === y) { | ||
throw new ArithmeticException('Invalid subtraction beyond MIN_SAFE_INTEGER!'); | ||
} | ||
return r; | ||
} | ||
static safeMultiply(x, y) { | ||
if (x == 1) { | ||
return y; | ||
} | ||
if (y == 1) { | ||
return x; | ||
} | ||
if (x == 0 || y == 0) { | ||
return 0; | ||
} | ||
let r = x * y; | ||
if (r < MIN_SAFE_INTEGER || r > MAX_SAFE_INTEGER || r / y != x || (x == MIN_SAFE_INTEGER && y == -1) || (y == MIN_SAFE_INTEGER && x == -1)) { | ||
throw new ArithmeticException('Multiplication overflows: ' + x + ' * ' + y); | ||
} | ||
return r; | ||
} | ||
/** | ||
* Compares two Numbers. | ||
* | ||
* @param {Number} a the first value | ||
* @param {Number} b the second value | ||
* @return {Number} the result | ||
*/ | ||
static compareNumbers(a, b) { | ||
if (a < b) { | ||
return -1; | ||
} | ||
if (a > b) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
} | ||
@@ -0,6 +1,10 @@ | ||
import {MAX_SAFE_INTEGER, MIN_SAFE_INTEGER} from '../MathUtil'; | ||
import { TemporalField } from './TemporalField'; | ||
import { ValueRange } from './ValueRange'; | ||
import {Year} from '../Year'; | ||
class ChronoField { | ||
export class ChronoField extends TemporalField { | ||
constructor(name, baseUnit, rangeUnit, range, displayNameKey) { | ||
super(); | ||
this.name = function () { | ||
@@ -26,17 +30,56 @@ return name; | ||
} | ||
/** | ||
* Get the range of valid values for this field using the temporal object to | ||
* refine the result. | ||
* <p> | ||
* This uses the temporal object to find the range of valid values for the field. | ||
* This is similar to {@link #range()}, however this method refines the result | ||
* using the temporal. For example, if the field is {@code DAY_OF_MONTH} the | ||
* {@code range} method is not accurate as there are four possible month lengths, | ||
* 28, 29, 30 and 31 days. Using this method with a date allows the range to be | ||
* accurate, returning just one of those four options. | ||
* <p> | ||
* There are two equivalent ways of using this method. | ||
* The first is to invoke this method directly. | ||
* The second is to use {@link TemporalAccessor#range(TemporalField)}: | ||
* <pre> | ||
* // these two lines are equivalent, but the second approach is recommended | ||
* temporal = thisField.rangeRefinedBy(temporal); | ||
* temporal = temporal.range(thisField); | ||
* </pre> | ||
* It is recommended to use the second approach, {@code range(TemporalField)}, | ||
* as it is a lot clearer to read in code. | ||
* <p> | ||
* Implementations should perform any queries or calculations using the fields | ||
* available in {@link ChronoField}. | ||
* If the field is not supported a {@code DateTimeException} must be thrown. | ||
* | ||
* @param {TemporalAccessor} temporal the temporal object used to refine the result, not null | ||
* @return {Va;lueRange} the range of valid values for this field, not null | ||
* @throws DateTimeException if the range for the field cannot be obtained | ||
*/ | ||
rangeRefinedBy(temporal) { | ||
return temporal.range(this); | ||
} | ||
} | ||
// TODO: why can't we use ChronoUnit.NANOS, ... in these initializers?? | ||
//ChronoField.NANO_OF_SECOND = new ChronoField('NanoOfSecond', ChronoUnit.NANOS, ChronoUnit.SECONDS, ValueRange.of(0, 999999999)); | ||
ChronoField.NANO_OF_SECOND = new ChronoField('NanoOfSecond', null, null, ValueRange.of(0, 999999999)); | ||
export const DAY_OF_MONTH = new ChronoField( | ||
"DayOfMonth", null, null, ValueRange.of(1, 28, 31), "day" | ||
); | ||
ChronoField.MICRO_OF_SECOND = new ChronoField('MicroOfSecond', null, null, ValueRange.of(0, 999999)); | ||
export const MONTH_OF_YEAR = new ChronoField( | ||
"MonthOfYear", null, null, ValueRange.of(1, 12), "month" | ||
); | ||
ChronoField.MILLI_OF_SECOND = new ChronoField('MilliOfSecond', null, null, ValueRange.of(0, 999)); | ||
export const YEAR = new ChronoField("" + | ||
"Year", null, null, ValueRange.of(-999999, 999999), "year" | ||
); | ||
ChronoField.DAY_OF_MONTH = new ChronoField('DayOfMonth', null, null, ValueRange.of(1, 28, 31), 'day'); | ||
ChronoField.MONTH_OF_YEAR = new ChronoField('MonthOfYear', null, null, ValueRange.of(1, 12), 'month'); | ||
ChronoField.YEAR = new ChronoField('Year', null, null, ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE), 'year'); | ||
ChronoField.INSTANT_SECONDS = new ChronoField('InstantSeconds', null, null, ValueRange.of(MIN_SAFE_INTEGER, MAX_SAFE_INTEGER)); | ||
import {assert} from '../assert'; | ||
import {DateTimeException} from '../errors'; | ||
@@ -23,8 +24,8 @@ /** | ||
constructor(minSmallest, minLargest, maxSmallest, maxLargest) { | ||
assert(!(minSmallest > minLargest), "Smallest minimum value '" + minSmallest + | ||
"' must be less than largest minimum value '" + minLargest + "'"); | ||
assert(!(maxSmallest > maxLargest), "Smallest maximum value '" + maxSmallest + | ||
"' must be less than largest maximum value '" + maxLargest + "'"); | ||
assert(!(minLargest > maxLargest), "Minimum value '" + minLargest + | ||
"' must be less than maximum value '" + maxLargest + "'"); | ||
assert(!(minSmallest > minLargest), 'Smallest minimum value \'' + minSmallest + | ||
'\' must be less than largest minimum value \'' + minLargest + '\''); | ||
assert(!(maxSmallest > maxLargest), 'Smallest maximum value \'' + maxSmallest + | ||
'\' must be less than largest maximum value \'' + maxLargest + '\''); | ||
assert(!(minLargest > maxLargest), 'Minimum value \'' + minLargest + | ||
'\' must be less than maximum value \'' + maxLargest + '\''); | ||
@@ -53,7 +54,7 @@ this.minimum = function () { | ||
if (field != null) { | ||
msg = ("Invalid value for " + field + " (valid values " + (this.toString()) + "): ") + value; | ||
msg = ('Invalid value for ' + field + ' (valid values ' + (this.toString()) + '): ') + value; | ||
} else { | ||
msg = ("Invalid value (valid values " + (this.toString()) + "): ") + value; | ||
msg = ('Invalid value (valid values ' + (this.toString()) + '): ') + value; | ||
} | ||
return assert(false, msg); | ||
return assert(false, msg, DateTimeException); | ||
} | ||
@@ -73,5 +74,5 @@ } | ||
toString() { | ||
var str = this.minimum() + (this.minimum() !== this.largestMinimum() ? "/" + (this.largestMinimum()) : ""); | ||
str += " - "; | ||
str += this.smallestMaximum() + (this.smallestMaximum() !== this.maximum() ? "/" + (this.maximum()) : ""); | ||
var str = this.minimum() + (this.minimum() !== this.largestMinimum() ? '/' + (this.largestMinimum()) : ''); | ||
str += ' - '; | ||
str += this.smallestMaximum() + (this.smallestMaximum() !== this.maximum() ? '/' + (this.maximum()) : ''); | ||
return str; | ||
@@ -119,5 +120,5 @@ } | ||
} else { | ||
return assert(false, "Invalid number of arguments " + arguments.length); | ||
return assert(false, 'Invalid number of arguments ' + arguments.length); | ||
} | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found
Found 1 instance in 1 package
676273
29
1
8435
101
1
21
1
+ Addedes6-error@^2.0.2
+ Addedes6-error@2.1.1(transitive)