You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
5.4 KiB
13 lines
5.4 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define(["exports","../core/string","../core/sql/UnknownTimeZone","../chunks/datetime"],function(f,u,h,d){function k(a,b,e){return a<b?a-b:a>e?a-e:0}function g(a,b=!0){if(a instanceof d.Zone)return a;if("system"===a.toLowerCase())return"system";if("utc"===a.toLowerCase())return"UTC";if("unknown"===a.toLowerCase())return h.UnknownTimeZone.instance;if(/^[+-]?[0-9]{1,2}([:][0-9]{2})?$/.test(a)){const e=d.FixedOffsetZone.parseSpecifier("UTC"+(a.startsWith("+")||a.startsWith("-")?"":"+")+a);if(e)return e}a= |
|
d.IANAZone.create(a);if(!a.isValid){if(b)throw new q(f.ArcadeDateErrorCodes.TimeZoneNotRecognized);return null}return a}f.ArcadeDateErrorCodes=void 0;(f.ArcadeDateErrorCodes||(f.ArcadeDateErrorCodes={})).TimeZoneNotRecognized="TimeZoneNotRecognized";const t={[f.ArcadeDateErrorCodes.TimeZoneNotRecognized]:"Timezone identifier has not been recognized."};class q extends Error{constructor(a,b){super(u.replace(t[a],b));this.declaredRootClass="esri.arcade.arcadedate.dateerror";Error.captureStackTrace&& |
|
Error.captureStackTrace(this,q)}}class c{constructor(a){this._date=a;this.declaredRootClass="esri.arcade.arcadedate"}static fromParts(a=0,b=1,e=1,l=0,m=0,n=0,p=0,v){if(isNaN(a)||isNaN(b)||isNaN(e)||isNaN(l)||isNaN(m)||isNaN(n)||isNaN(p))return null;const r=d.DateTime.local(a,b).daysInMonth;a=d.DateTime.fromObject({day:1>e?1:e>r?r:e,year:a,month:1>b?1:12<b?12:b,hour:0>l?0:23<l?23:l,minute:0>m?0:59<m?59:m,second:0>n?0:59<n?59:n,millisecond:0>p?0:999<p?999:p},{zone:g(v)});a=a.plus({months:k(b,1,12), |
|
days:k(e,1,r),hours:k(l,0,23),minutes:k(m,0,59),seconds:k(n,0,59),milliseconds:k(p,0,999)});return new c(a)}static get systemTimeZoneCanonicalName(){return Intl.DateTimeFormat().resolvedOptions().timeZone??"system"}static arcadeDateAndZoneToArcadeDate(a,b){b=g(b);return a.isUnknownTimeZone||b===h.UnknownTimeZone.instance?c.fromParts(a.year,a.monthJS+1,a.day,a.hour,a.minute,a.second,a.millisecond,b):new c(a._date.setZone(b))}static dateJSToArcadeDate(a){return new c(d.DateTime.fromJSDate(a,{zone:"system"}))}static dateJSAndZoneToArcadeDate(a, |
|
b="system"){b=g(b);return new c(d.DateTime.fromJSDate(a,{zone:b}))}static unknownEpochToArcadeDate(a){return new c(d.DateTime.fromMillis(a,{zone:h.UnknownTimeZone.instance}))}static unknownDateJSToArcadeDate(a){return new c(d.DateTime.fromMillis(a.getTime(),{zone:h.UnknownTimeZone.instance}))}static epochToArcadeDate(a,b="system"){b=g(b);return new c(d.DateTime.fromMillis(a,{zone:b}))}static dateTimeToArcadeDate(a){return new c(a)}clone(){return new c(this._date)}changeTimeZone(a){a=g(a);return c.dateTimeToArcadeDate(this._date.setZone(a))}static dateTimeAndZoneToArcadeDate(a, |
|
b){b=g(b);return a.zone===h.UnknownTimeZone.instance||b===h.UnknownTimeZone.instance?c.fromParts(a.year,a.month,a.day,a.hour,a.minute,a.second,a.millisecond,b):new c(a.setZone(b))}static nowToArcadeDate(a){a=g(a);return new c(d.DateTime.fromJSDate(new Date,{zone:a}))}static nowUTCToArcadeDate(){return new c(d.DateTime.utc())}get isSystem(){return"system"===this.timeZone||this.timeZone===c.systemTimeZoneCanonicalName}equals(a){return this.isSystem&&a.isSystem?this.toNumber()===a.toNumber():this.isUnknownTimeZone!== |
|
a.isUnknownTimeZone?!1:this._date.equals(a._date)}get isUnknownTimeZone(){return this._date.zone===h.UnknownTimeZone.instance}get isValid(){return this._date.isValid}get hour(){return this._date.hour}get second(){return this._date.second}get day(){return this._date.day}get dayOfWeekISO(){return this._date.weekday}get dayOfWeekJS(){let a=this._date.weekday;6<a&&(a=0);return a}get millisecond(){return this._date.millisecond}get monthISO(){return this._date.month}get weekISO(){return this._date.weekNumber}get yearISO(){return this._date.weekYear}get monthJS(){return this._date.month- |
|
1}get year(){return this._date.year}get minute(){return this._date.minute}get zone(){return this._date.zone}get timeZoneOffset(){return this.isUnknownTimeZone?0:this._date.offset}get timeZone(){if(this.isUnknownTimeZone)return"unknown";if("system"===this._date.zone.type)return"system";const a=this.zone;return"fixed"===a.type?0===a.fixed?"UTC":a.formatOffset(0,"short"):a.name}stringify(){return JSON.stringify(this.toJSDate())}plus(a){return new c(this._date.plus(a))}diff(a,b="milliseconds"){return this._date.diff(a._date, |
|
b)[b]}toISODate(){return this._date.toISODate()}toISOString(a){return a?this._date.toISO({suppressMilliseconds:!0,includeOffset:!this.isUnknownTimeZone}):this._date.toISO({includeOffset:!this.isUnknownTimeZone})}toISOTime(a,b){return this._date.toISOTime({suppressMilliseconds:a,includeOffset:b&&!this.isUnknownTimeZone})}toFormat(a,b){this.isUnknownTimeZone&&(a=a.replaceAll("Z",""));return this._date.toFormat(a,b)}toJSDate(){return this._date.toJSDate()}toSQLValue(){return this._date.toFormat("yyyy-LL-dd HH:mm:ss")}toSQLWithKeyword(){return`timestamp '${this.toSQLValue()}'`}toDateTime(){return this._date}toNumber(){return this._date.toMillis()}getTime(){return this._date.toMillis()}toUTC(){return new c(this._date.toUTC())}toLocal(){return new c(this._date.toLocal())}toString(){return this.toISOString(!0)}static fromReaderAsTimeStampOffset(a){if(!a)return null; |
|
a=d.DateTime.fromISO(a,{setZone:!0});return new c(a)}}f.ArcadeDate=c;f.ArcadeDateError=q;f.arcadeDateErrorMessages=t;f.createDateTimeZone=g;Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}); |