Files
dajiankang-uniapp/unpackage/dist/build/mp-weixin/uni_modules/wot-design-uni/dayjs/index.js
PC-202306242200\Administrator 1c24452b6c first commit
2026-03-28 23:10:55 +08:00

2 lines
6.0 KiB
JavaScript

"use strict";const t=require("./constant.js"),e=require("./locale/en.js"),r=require("./utils.js");var n="en",s={};s[n]=e.en;var i=function(t){return t instanceof o||!(!t||!t.$isDayjsObject)},u=function t(e,r,i){var u;if(!e)return n;if("string"==typeof e){var a=e.toLowerCase();s[a]&&(u=a),r&&(s[a]=r,u=a);var c=e.split("-");if(!u&&c.length>1)return t(c[0])}else{var o=e.name;s[o]=e,u=o}return!i&&u&&(n=u),u||!i&&n},a=function(t,e){if(i(t))return t.clone();var r="object"==typeof e?e:{};return r.date=t,r.args=arguments,new o(r)},c=r.U;c.l=u,c.i=i,c.w=function(t,e){return a(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var o=function(){function e(t){this.$L=u(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this.$isDayjsObject=!0}var r=e.prototype;return r.parse=function(e){this.$d=function(e){var r=e.date,n=e.utc;if(null===r)return new Date(NaN);if(c.u(r))return new Date;if(r instanceof Date)return new Date(r);if("string"==typeof r&&!/Z$/i.test(r)){var s=r.match(t.REGEX_PARSE);if(s){var i=s[2]-1||0,u=(s[7]||"0").substring(0,3);return n?new Date(Date.UTC(s[1],i,s[3]||1,s[4]||0,s[5]||0,s[6]||0,u)):new Date(s[1],i,s[3]||1,s[4]||0,s[5]||0,s[6]||0,u)}}return new Date(r)}(e),this.init()},r.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},r.$utils=function(){return c},r.isValid=function(){return!(this.$d.toString()===t.INVALID_DATE_STRING)},r.isSame=function(t,e){var r=a(t);return this.startOf(e)<=r&&r<=this.endOf(e)},r.isAfter=function(t,e){return a(t)<this.startOf(e)},r.isBefore=function(t,e){return this.endOf(e)<a(t)},r.$g=function(t,e,r){return c.u(t)?this[e]:this.set(r,t)},r.unix=function(){return Math.floor(this.valueOf()/1e3)},r.valueOf=function(){return this.$d.getTime()},r.startOf=function(e,r){var n=this,s=!!c.u(r)||r,i=c.p(e),u=function(e,r){var i=c.w(n.$u?Date.UTC(n.$y,r,e):new Date(n.$y,r,e),n);return s?i:i.endOf(t.D)},a=function(t,e){return c.w(n.toDate()[t].apply(n.toDate("s"),(s?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},o=this.$W,f=this.$M,h=this.$D,$="set"+(this.$u?"UTC":"");switch(i){case t.Y:return s?u(1,0):u(31,11);case t.M:return s?u(1,f):u(0,f+1);case t.W:var l=this.$locale().weekStart||0,D=(o<l?o+7:o)-l;return u(s?h-D:h+(6-D),f);case t.D:case t.DATE:return a($+"Hours",0);case t.H:return a($+"Minutes",1);case t.MIN:return a($+"Seconds",2);case t.S:return a($+"Milliseconds",3);default:return this.clone()}},r.endOf=function(t){return this.startOf(t,!1)},r.$set=function(e,r){var n,s=c.p(e),i="set"+(this.$u?"UTC":""),u=(n={},n[t.D]=i+"Date",n[t.DATE]=i+"Date",n[t.M]=i+"Month",n[t.Y]=i+"FullYear",n[t.H]=i+"Hours",n[t.MIN]=i+"Minutes",n[t.S]=i+"Seconds",n[t.MS]=i+"Milliseconds",n)[s],a=s===t.D?this.$D+(r-this.$W):r;if(s===t.M||s===t.Y){var o=this.clone().set(t.DATE,1);o.$d[u](a),o.init(),this.$d=o.set(t.DATE,Math.min(this.$D,o.daysInMonth())).$d}else u&&this.$d[u](a);return this.init(),this},r.set=function(t,e){return this.clone().$set(t,e)},r.get=function(t){return this[c.p(t)]()},r.add=function(e,r){var n,s=this;e=Number(e);var i=c.p(r),u=function(t){var r=a(s);return c.w(r.date(r.date()+Math.round(t*e)),s)};if(i===t.M)return this.set(t.M,this.$M+e);if(i===t.Y)return this.set(t.Y,this.$y+e);if(i===t.D)return u(1);if(i===t.W)return u(7);var o=(n={},n[t.MIN]=t.MILLISECONDS_A_MINUTE,n[t.H]=t.MILLISECONDS_A_HOUR,n[t.S]=t.MILLISECONDS_A_SECOND,n)[i]||1,f=this.$d.getTime()+e*o;return c.w(f,this)},r.subtract=function(t,e){return this.add(-1*t,e)},r.format=function(e){var r=this,n=this.$locale();if(!this.isValid())return n.invalidDate||t.INVALID_DATE_STRING;var s=e||t.FORMAT_DEFAULT,i=c.z(this),u=this.$H,a=this.$m,o=this.$M,f=n.weekdays,h=n.months,$=n.meridiem,l=function(t,e,n,i){return t&&(t[e]||t(r,s))||n[e].slice(0,i)},D=function(t){return c.s(u%12||12,t,"0")},M=$||function(t,e,r){var n=t<12?"AM":"PM";return r?n.toLowerCase():n};return s.replace(t.REGEX_FORMAT,(function(t,e){return e||function(t){switch(t){case"YY":return String(r.$y).slice(-2);case"YYYY":return c.s(r.$y,4,"0");case"M":return o+1;case"MM":return c.s(o+1,2,"0");case"MMM":return l(n.monthsShort,o,h,3);case"MMMM":return l(h,o);case"D":return r.$D;case"DD":return c.s(r.$D,2,"0");case"d":return String(r.$W);case"dd":return l(n.weekdaysMin,r.$W,f,2);case"ddd":return l(n.weekdaysShort,r.$W,f,3);case"dddd":return f[r.$W];case"H":return String(u);case"HH":return c.s(u,2,"0");case"h":return D(1);case"hh":return D(2);case"a":return M(u,a,!0);case"A":return M(u,a,!1);case"m":return String(a);case"mm":return c.s(a,2,"0");case"s":return String(r.$s);case"ss":return c.s(r.$s,2,"0");case"SSS":return c.s(r.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},r.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},r.diff=function(e,r,n){var s,i=this,u=c.p(r),o=a(e),f=(o.utcOffset()-this.utcOffset())*t.MILLISECONDS_A_MINUTE,h=this-o,$=function(){return c.m(i,o)};switch(u){case t.Y:s=$()/12;break;case t.M:s=$();break;case t.Q:s=$()/3;break;case t.W:s=(h-f)/t.MILLISECONDS_A_WEEK;break;case t.D:s=(h-f)/t.MILLISECONDS_A_DAY;break;case t.H:s=h/t.MILLISECONDS_A_HOUR;break;case t.MIN:s=h/t.MILLISECONDS_A_MINUTE;break;case t.S:s=h/t.MILLISECONDS_A_SECOND;break;default:s=h}return n?s:c.a(s)},r.daysInMonth=function(){return this.endOf(t.M).$D},r.$locale=function(){return s[this.$L]},r.locale=function(t,e){if(!t)return this.$L;var r=this.clone(),n=u(t,e,!0);return n&&(r.$L=n),r},r.clone=function(){return c.w(this.$d,this)},r.toDate=function(){return new Date(this.valueOf())},r.toJSON=function(){return this.isValid()?this.toISOString():null},r.toISOString=function(){return this.$d.toISOString()},r.toString=function(){return this.$d.toUTCString()},e}(),f=o.prototype;a.prototype=f,[["$ms",t.MS],["$s",t.S],["$m",t.MIN],["$H",t.H],["$W",t.D],["$M",t.M],["$y",t.Y],["$D",t.DATE]].forEach((function(t){f[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),a.extend=function(t,e){return t.$i||(t(e,o,a),t.$i=!0),a},a.locale=u,a.isDayjs=i,a.unix=function(t){return a(1e3*t)},a.en=s[n],a.Ls=s,a.p={},exports.dayjs=a;