mat-date 1.5.81 → 1.5.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DateUtil.d.ts +3 -0
- package/dist/DateUtil.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/DateUtil.d.ts
CHANGED
|
@@ -24,6 +24,9 @@ export declare class MDateUtil {
|
|
|
24
24
|
cpy(): MDateUtil;
|
|
25
25
|
setCode(code: string): this;
|
|
26
26
|
seperator(): string;
|
|
27
|
+
zone(): string;
|
|
28
|
+
zones(code?: string): string[];
|
|
29
|
+
region(code?: string): string;
|
|
27
30
|
year(): number;
|
|
28
31
|
month(): number;
|
|
29
32
|
monthUtc(): number;
|
package/dist/DateUtil.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MDateUtil=void 0;const padItem=(t,e=2)=>t.toString().padStart(e,"0");class MDateUtil{val=new Date;static glCode=void 0;code=void 0;get localCode(){return this.code}static new(){return(new MDateUtil).setCode(MDateUtil.glCode)}static setCode(t){return MDateUtil.glCode=t,this}static seperator(){return(new Date).toLocaleDateString(MDateUtil.glCode).replace(/\d/g,"").split("")[0]}cpy(){return MDateUtil.new().setTime(this.toTime())}setCode(t){return this.code=t,this}seperator(){return(new Date).toLocaleDateString(this.code).replace(/\d/g,"").split("")[0]}zone(){try{return Intl.DateTimeFormat()?.resolvedOptions()?.timeZone}catch(t){return null}}zones(t=this.code){try{return new Intl.Locale(t)?.timeZones||[]}catch(t){return null}}region(t=this.code){try{return new Intl.Locale(t).region}catch(t){return null}}year(){return this.val.getFullYear()}month(){return this.val.getMonth()+1}monthUtc(){return this.val.getMonth()}day(){return this.val.getDate()}hours(){return this.val.getHours()}min(){return this.val.getMinutes()}sec(){return this.val.getSeconds()}dayOfWeek(){var t=this.val.getDay();return t||7}dayOfWeekUtc(){return this.val.getDay()}setYear(t){return this.val.setFullYear(t),this}setMonth(t){return this.val.setMonth(t-1),this}setMonthUtc(t){return this.val.setMonth(t),this}setDay(t){return this.val.setDate(t),this}setHour(t){return this.val.setHours(t),this}startOfHours(){return this.setHour(0),this.setMin(0),this.setSeconds(0),this.setMilliseconds(0),this}endOfHours(){return this.setHour(23),this.setMin(59),this.setSeconds(59),this.setMilliseconds(999),this}setMin(t){return this.val.setMinutes(t),this}startOfMin(){return this.setMin(0),this.setSeconds(0),this.setMilliseconds(0),this}endOfMin(){return this.setMin(59),this.setSeconds(59),this.setMilliseconds(999),this}setSeconds(t){return this.val.setSeconds(t),this}startOfSeconds(){return this.setSeconds(0),this.setMilliseconds(0),this}endOfSeconds(){return this.setSeconds(59),this.setMilliseconds(999),this}setMilliseconds(t){return this.val.setMilliseconds(t),this}startOfMilliseconds(){return this.setMilliseconds(0),this}endOfMilliseconds(){return this.setMilliseconds(999),this}setIsoDate(t){return this.val=new Date(t),this}setTime(t){return this.val=new Date(t),this}setDate(t){return this.val=new Date(t),this}setDateInputValue(t){return this.val=new Date(t?.replace("T"," ")),this}toIsoDate(){return this.val.toISOString()}toTime(){return this.val.getTime()}toDate(){return this.val}toDateMounthInput(){return this.year()+"-"+padItem(this.month())}toDateInput(){return`${this.year()}-${padItem(this.month())}-`+padItem(this.day())}toTimeInput(t=!0){var e=[];return e.push(padItem(this.hours())),e.push(padItem(this.min())),t&&e.push(padItem(this.sec())),e.join(":")}toDateTimeInput(t=!0){return this.toDateInput()+"T"+this.toTimeInput(t)}strDate(){return this.val.toLocaleDateString(this.code,{month:"2-digit",day:"2-digit",year:"numeric"})}strDateLocal(t){return this.val.toLocaleDateString(this.code,t)}strTime(){return`${padItem(this.hours())}:${padItem(this.min())}:`+padItem(this.sec())}strTimeLocale(t){return this.val.toLocaleTimeString(this.code,t)}strHHmm(){return padItem(this.hours())+":"+padItem(this.min())}str(){return this.strDate()+" "+this.strTime()}strLocal(t){return this.val.toLocaleString(this.code,t)}addDay(t){return this.val=new Date(this.val.setHours(this.val.getHours()+24*t)),this}addHours(t){return this.val=new Date(this.val.setHours(this.val.getHours()+t)),this}addMins(t){return this.val=new Date(this.val.setMinutes(this.val.getMinutes()+t)),this}startOfDay(){return this.startOfHours(),this}cpyByStartOfDay(){return this.cpy().startOfDay()}endOfDay(){return this.endOfHours(),this}cpyByEndOfDay(){return this.cpy().endOfDay()}startOfWeek(){return this.addDay(1-this.dayOfWeek())}cpyStartOfWeek(){return this.cpy().addDay(1-this.dayOfWeek())}endOfWeek(){return this.startOfWeek().addDay(6)}cpyEndOfWeek(){return this.cpyStartOfWeek().addDay(6)}startOfMonth(){return this.setDay(1),this.startOfDay(),this}cpyByStartOfMonth(){return this.cpy().startOfMonth()}endOfMonth(){return this.setDate(this.val).startOfMonth().setMonth(this.month()+1).startOfMonth().addDay(-1).endOfDay(),this}cpyByEndOfMonth(){return this.cpy().endOfMonth()}static diffDays(t,e,s){try{var r=parse(t),i=parse(e);return s?Math.abs(r-i)/36e5/24:(r-i)/36e5/24}catch(t){throw new Error("UNKNOWN")}}static diffHours(t,e,s){try{var r=parse(t),i=parse(e);return s?Math.abs(r-i)/36e5:(r-i)/36e5}catch(t){throw new Error("UNKNOWN")}}static diffMins(t,e,s){try{var r=parse(t),i=parse(e);return s?Math.abs(r-i)/1e3/60:(r-i)/1e3/60}catch(t){throw new Error("UNKNOWN")}}static diffSecs(t,e,s){try{var r=parse(t),i=parse(e);return s?Math.abs(r-i)/1e3:(r-i)/1e3}catch(t){throw new Error("UNKNOWN")}}}function parse(t){try{return t instanceof MDateUtil?t.toTime():t instanceof Date?t.getTime():"number"==typeof t?t:"string"==typeof t?new Date(t).getTime():0}catch(t){throw new Error("ERROR")}}exports.MDateUtil=MDateUtil;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&("get"in n?t.__esModule:!n.writable&&!n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){e[i=void 0===i?r:i]=t[r]}),__exportStar=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||__createBinding(t,e,r)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./DateUtil"),exports);
|