datex.js 1.0.9 → 1.0.10

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/datex.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * datex.js v1.0.9
2
+ * datex.js v1.0.10
3
3
  * a datetime format library
4
4
  * https://passer-by.com/datex/
5
5
  *
@@ -8,6 +8,6 @@
8
8
  * Released under the MIT License
9
9
  * https://github.com/mumuy/datex
10
10
  *
11
- * Created on: 2023-05-10
11
+ * Created on: 2023-06-29
12
12
  */
13
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).datex=e()}(this,(function(){"use strict";let t={"en-US":{MMM:["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sept.","Oct.","Nov.","Dec."],MMMM:["January","February","March","April","May","June","July","August","September","October","November","December"],Do:["1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st"],WW:["Sun.","Mon.","Tues.","Wed.","Thur.","Fri.","Sat."],WWW:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},"zh-CN":{MMM:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],MMMM:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],Do:["1日","2日","3日","4日","5日","6日","7日","8日","9日","10日","11日","12日","13日","14日","15日","16日","17日","18日","19日","20日","21日","22日","23日","24日","25日","26日","27日","28日","29日","30日","31日"],WW:["周日","周一","周二","周三","周四","周五","周六"],WWW:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]}},e="en-US";"undefined"!=typeof self&&self.navigator&&(e=self.navigator.language);let n=Intl.DateTimeFormat().resolvedOptions().timeZone,i=0;const a=["year","month","day","hour","minute","second","millsecond"],s=[1970,1,1,0,0,0,0],r=(t,e)=>new Date(t.toLocaleString("en-US",{timeZone:e}));function o(...t){return new o.prototype.init(...t)}function h(t){return t instanceof o?t:o(t)}return o.setLanguage=function(e,n={}){return t[e]=Object.assign(t[e]||{},n),this},o.switchLanguage=function(t){return e=t,this},o.now=Date.now,o.switchTimezone=function(t){n=t,i=r(new Date("1970/1/1"),n).getTime()-new Date("1970/1/1").getTime()},o.getTimezone=function(){return n},o.prototype={_date:null,_langMap:{},_lang:null,_timezone:null,_offset:0,init:function(...t){if(t.length){if(t[0]instanceof Date)this._date=t[0];else{if(Array.isArray(t[0])?t=s.map(((e,n)=>t[0][n]||e)):null==(e=t[0])||"object"!=typeof e&&"function"!=typeof e||(t=s.map(((e,n)=>t[0][a[n]]||e))),1==t.length&&"string"==typeof t[0]){let e=t[0].match(/(\d{1,4})[\-\/](\d{1,2})[\-\/](\d{1,2})([\sT](\d{1,2})?:(\d{1,2})?(:(\d{1,2}))?(\.(\d{1,3}))?)?/),n=t[0].match(/(\d{1,2})[\-\/](\d{1,2})[\-\/](\d{3,4})([\sT](\d{1,2})?:(\d{1,2})?(:(\d{1,2}))?(\.(\d{1,3}))?)?/),i=t[0].match(/^([12]\d{3})(\d{2})(\d{2})(\d{2})?(\d{2})?(\d{2})?(\d{1,3})?/);e&&!n?t=[1,2,3,5,6,8,10].map((function(t,n){return+(e[t]||s[n])})):n?t=[3,1,2,5,6,8,10].map((function(t,e){return+(n[t]||s[e])})):i&&(t=[1,2,3,4,5,6,7].map((function(t,e){return+(i[t]||s[e])})))}t.length>=3&&t[1]--,this._date=new Date(...t),t.length>=2&&!isNaN(t[0])&&t[0]<100&&this._date.setFullYear(t[0])}i&&this._date.setTime(this._date.getTime()-i)}else this._date=new Date;var e;return this},setLanguage(t,e={}){return this._langMap[t]=Object.assign(this._langMap[t]||{},e),this},switchLanguage(t){return this._lang=t,this},switchTimezone(t){return this._timezone=t,this._offset=r(new Date("1970/1/1"),this._timezone).getTime()-new Date("1970/1/1").getTime(),this},getTimezone(){return this._timezone||n},getTime(){return this._date.getTime()},getUnix(){return~~(this._date.getTime()/1e3)},clone(){return o(this.getTime())},toDate(){return this._date},toObject(){let t=this._date;return{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millsecond:t.getMilliseconds(),timestamp:t.getTime(),week:t.getDay()}},toArray(){let t=this.toObject();return a.map((e=>t[e]))},toString(){return this._date.toString()},toISOString(){return this._date.toISOString()},set(t,e){let n=this._date,i=this.toObject();switch(t){case"year":n.setFullYear(e);break;case"month":n.setMonth(e-1);break;case"day":n.setDate(e);break;case"hour":n.setHours(e);break;case"minute":n.setMinutes(e);break;case"second":n.setSeconds(e);break;case"millsecond":n.setMilliseconds(e);break;case"timestamp":n.setTime(e);break;case"week":n.setDate(i.day-i.week+e)}return this},get(t){return this.toObject()[t]},change(t,e){let n=this.toObject();return this.set(t,n[t]+e)},format(n="YYYY-MM-DD HH:mm:ss"){let a=this.clone(),s=this._offset||i;a._date.setTime(this._date.getTime()+s);let r=a._date,o=a.toObject(),h=r.toTimeString().match(/GMT([\+\-])(\d{2})(\d{2})/),d={YYYY:""+o.year,YY:(""+o.year).padStart(2,"0"),MM:(""+o.month).padStart(2,"0"),M:""+o.month,DD:(""+o.day).padStart(2,"0"),D:""+o.day,HH:(""+o.hour).padStart(2,"0"),H:""+o.hour,hh:(""+o.hour%12).padStart(2,"0"),h:""+o.hour%12,mm:(""+o.minute).padStart(2,"0"),m:""+o.minute,ss:(""+o.second).padStart(2,"0"),s:""+o.second,S:""+~~(o.millsecond%1e3/100),SS:""+~~(o.millsecond%1e3/10),SSS:""+o.millsecond%1e3,Z:h[1]+h[2]+":"+h[3],ZZ:h[1]+h[2]+h[3],A:["AM","PM"][~~(o.hour/12)],a:["am","pm"][~~(o.hour/12)],X:o.timestamp,x:~~(o.timestamp/1e3),Q:""+~~(o.month/3),W:o.week},m=Object.assign({},t,this._langMap)[this._lang||e];return d.MMM=m.MMM[o.month-1],d.MMMM=m.MMMM[o.month-1],d.Do=m.Do[o.day-1],d.WW=m.WW[o.week],d.WWW=m.WWW[o.week],n.replace(/Y+|M+|D+|H+|h+|m+|s+|S+|Z+|Do|A|a|X|x|Q|W+/g,(function(t){return d[t]||""}))},startOf(t){let e=this.toObject(),n=null,i=a.indexOf(t)+1,r=this.toArray(),h=s.slice(i);return r.splice(i,h.length,...h),n="timestamp"==t?this.clone():"week"==t?o(e.year,e.month,e.day-e.week,0,0,0,0):o(...r),n},endOf(t){return this.startOf(t).change(t,"week"==t?7:1).change("millsecond",-1)},diffWith(t,e){if(!(t=h(t)).isValid())return!1;let n={day:864e5,hour:36e5,minute:6e4,second:1e3,millsecond:1},i=this.getTime()-t.getTime(),s=0;if(e){if(n[e])s=~~(i/n[e]);else if("month"==e){s=12*(this.get("year")-1)+this.get("month")-(12*(t.get("year")-1)+t.get("month")),s<0&&this.get("day")>t.get("day")?s+=1:s>0&&this.get("day")<t.get("day")&&(s-=1)}else"year"==e&&(s=this.get("year")-t.get("year"),s<0&&(this.get("month")>t.get("month")||this.get("month")==t.get("month")&&this.get("day")>t.get("day"))?s+=1:s>0&&(this.get("month")<t.get("month")||this.get("month")==t.get("month")&&this.get("day")<t.get("day"))&&(s-=1));return s}{let e=this.clone(),n={};return a.forEach((function(i){n[i]=e.diffWith(t,i),e.set(i,t.get(i))})),n}},isBefore(t,e="timestamp"){return t=h(t),this.get(e)<t.get(e)},isAfter(t,e="timestamp"){return t=h(t),this.get(e)>t.get(e)},isSame(t,e="timestamp"){return t=h(t),this.get(e)==t.get(e)},isBetween(t,e,n="timestamp"){return t=h(t),e=h(e),this.get(n)>t.get(n)&&this.get(n)<e.get(n)},isValid(){return!isNaN(this.getTime())}},o.prototype.init.prototype=o.prototype,o}));
13
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).datex=e()}(this,(function(){"use strict";let t={"en-us":{MMM:["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sept.","Oct.","Nov.","Dec."],MMMM:["January","February","March","April","May","June","July","August","September","October","November","December"],Do:["1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st"],WW:["Sun.","Mon.","Tues.","Wed.","Thur.","Fri.","Sat."],WWW:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},"zh-cn":{MMM:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],MMMM:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],Do:["1日","2日","3日","4日","5日","6日","7日","8日","9日","10日","11日","12日","13日","14日","15日","16日","17日","18日","19日","20日","21日","22日","23日","24日","25日","26日","27日","28日","29日","30日","31日"],WW:["周日","周一","周二","周三","周四","周五","周六"],WWW:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]}},e="en-us";"undefined"!=typeof self&&self.navigator&&(e=self.navigator.language.toLowerCase(),t[e]||(e="en-us"));let n=Intl.DateTimeFormat().resolvedOptions().timeZone,i=0;const s=["year","month","day","hour","minute","second","millsecond"],a=[1970,1,1,0,0,0,0],r=(t,e)=>new Date(t.toLocaleString("en-US",{timeZone:e}));function o(...t){return new o.prototype.init(...t)}function h(t){return t instanceof o?t:o(t)}return o.setLanguage=function(e,n={}){return t[e]=Object.assign(t[e]||{},n),this},o.switchLanguage=function(t){return e=t,this},o.now=Date.now,o.supportedTimezones="undefined"!=typeof Intl&&Intl.supportedValuesOf?Intl.supportedValuesOf("timeZone"):[],o.switchTimezone=function(t){n=t,i=r(new Date("1970/1/1"),n).getTime()-new Date("1970/1/1").getTime()},o.getTimezone=function(){return n},o.getTimezoneOffset=function(){return(new Date).getTimezoneOffset()-i/6e4},o.prototype={_date:null,_langMap:{},_lang:null,_timezone:null,_offset:0,init:function(...t){if(t.length){if(t[0]instanceof Date)this._date=t[0];else{if(Array.isArray(t[0])?t=a.map(((e,n)=>t[0][n]||e)):null==(e=t[0])||"object"!=typeof e&&"function"!=typeof e||(t=a.map(((e,n)=>t[0][s[n]]||e))),1==t.length&&"string"==typeof t[0]){let e=t[0].match(/(\d{1,4})[\-\/](\d{1,2})[\-\/](\d{1,2})([\sT](\d{1,2})?:(\d{1,2})?(:(\d{1,2}))?(\.(\d{1,3}))?)?/),n=t[0].match(/(\d{1,2})[\-\/](\d{1,2})[\-\/](\d{3,4})([\sT](\d{1,2})?:(\d{1,2})?(:(\d{1,2}))?(\.(\d{1,3}))?)?/),i=t[0].match(/^([12]\d{3})(\d{2})(\d{2})(\d{2})?(\d{2})?(\d{2})?(\d{1,3})?/);e&&!n?t=[1,2,3,5,6,8,10].map((function(t,n){return+(e[t]||a[n])})):n?t=[3,1,2,5,6,8,10].map((function(t,e){return+(n[t]||a[e])})):i&&(t=[1,2,3,4,5,6,7].map((function(t,e){return+(i[t]||a[e])})))}t.length>=3&&t[1]--,this._date=new Date(...t),t.length>=2&&!isNaN(t[0])&&t[0]<100&&this._date.setFullYear(t[0])}i&&this._date.setTime(this._date.getTime()-i)}else this._date=new Date;var e;return this},getTime(){return this._date.getTime()},getUnix(){return~~(this._date.getTime()/1e3)},clone(){return o(this.getTime())},toDate(){return this._date},toObject(){let t=this._date;return{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millsecond:t.getMilliseconds(),timestamp:t.getTime(),week:t.getDay()}},toArray(){let t=this.toObject();return s.map((e=>t[e]))},toString(){return this._date.toString()},toISOString(){return this._date.toISOString()},set(t,e){let n=this._date,i=this.toObject();switch(t){case"year":n.setFullYear(e);break;case"month":n.setMonth(e-1);break;case"day":n.setDate(e);break;case"hour":n.setHours(e);break;case"minute":n.setMinutes(e);break;case"second":n.setSeconds(e);break;case"millsecond":n.setMilliseconds(e);break;case"timestamp":n.setTime(e);break;case"week":n.setDate(i.day-i.week+e)}return this},get(t){return this.toObject()[t]},change(t,e){let n=this.toObject();return this.set(t,n[t]+e)},format(n="YYYY-MM-DD HH:mm:ss"){let s=this.clone(),a=this._offset||i;s._date.setTime(this._date.getTime()+a);let r=s._date,o=s.toObject(),h=r.toTimeString().match(/GMT([\+\-])(\d{2})(\d{2})/),d={YYYY:""+o.year,YY:(""+o.year).padStart(2,"0"),MM:(""+o.month).padStart(2,"0"),M:""+o.month,DD:(""+o.day).padStart(2,"0"),D:""+o.day,HH:(""+o.hour).padStart(2,"0"),H:""+o.hour,hh:(""+o.hour%12).padStart(2,"0"),h:""+o.hour%12,mm:(""+o.minute).padStart(2,"0"),m:""+o.minute,ss:(""+o.second).padStart(2,"0"),s:""+o.second,S:""+~~(o.millsecond%1e3/100),SS:""+~~(o.millsecond%1e3/10),SSS:""+o.millsecond%1e3,Z:h[1]+h[2]+":"+h[3],ZZ:h[1]+h[2]+h[3],A:["AM","PM"][~~(o.hour/12)],a:["am","pm"][~~(o.hour/12)],X:o.timestamp,x:~~(o.timestamp/1e3),Q:""+~~(o.month/3),W:o.week},u=Object.assign({},t,this._langMap)[this._lang||e];return d.MMM=u.MMM[o.month-1],d.MMMM=u.MMMM[o.month-1],d.Do=u.Do[o.day-1],d.WW=u.WW[o.week],d.WWW=u.WWW[o.week],n.replace(/Y+|M+|D+|H+|h+|m+|s+|S+|Z+|Do|A|a|X|x|Q|W+/g,(function(t){return d[t]||""}))},startOf(t){let e=this.toObject(),n=null,i=s.indexOf(t)+1,r=this.toArray(),h=a.slice(i);return r.splice(i,h.length,...h),n="timestamp"==t?this.clone():"week"==t?o(e.year,e.month,e.day-e.week,0,0,0,0):o(...r),n},endOf(t){return this.startOf(t).change(t,"week"==t?7:1).change("millsecond",-1)},diffWith(t,e){if(!(t=h(t)).isValid())return!1;let n={day:864e5,hour:36e5,minute:6e4,second:1e3,millsecond:1},i=this.getTime()-t.getTime(),a=0;if(e){if(n[e])a=~~(i/n[e]);else if("month"==e){a=12*(this.get("year")-1)+this.get("month")-(12*(t.get("year")-1)+t.get("month")),a<0&&this.get("day")>t.get("day")?a+=1:a>0&&this.get("day")<t.get("day")&&(a-=1)}else"year"==e&&(a=this.get("year")-t.get("year"),a<0&&(this.get("month")>t.get("month")||this.get("month")==t.get("month")&&this.get("day")>t.get("day"))?a+=1:a>0&&(this.get("month")<t.get("month")||this.get("month")==t.get("month")&&this.get("day")<t.get("day"))&&(a-=1));return a}{let e=this.clone(),n={};return s.forEach((function(i){n[i]=e.diffWith(t,i),e.set(i,t.get(i))})),n}},isBefore(t,e="timestamp"){return t=h(t),this.get(e)<t.get(e)},isAfter(t,e="timestamp"){return t=h(t),this.get(e)>t.get(e)},isSame(t,e="timestamp"){return t=h(t),this.get(e)==t.get(e)},isBetween(t,e,n="timestamp"){return t=h(t),e=h(e),this.get(n)>t.get(n)&&this.get(n)<e.get(n)},setLanguage(t,e={}){return t=t.toLowerCase(),this._langMap[t]=Object.assign(this._langMap[t]||{},e),this},switchLanguage(t){return this._lang=t.toLowerCase(),this},switchTimezone(t){return this._timezone=t,this._offset=r(new Date("1970/1/1"),this._timezone).getTime()-new Date("1970/1/1").getTime(),this},getTimezone(){return this._timezone||n},getTimezoneOffset(){return this._date.getTimezoneOffset()-(this._offset||i)/6e4},isValid(){return!isNaN(this.getTime())}},o.prototype.init.prototype=o.prototype,o}));
package/index.html CHANGED
@@ -179,8 +179,21 @@
179
179
  <span class="subtitle">switchTimezone(timezone)</span>
180
180
  </a>
181
181
  </li>
182
+
182
183
  <li>
183
184
  <a href="#hash25">
185
+ <span class="title">获取支持时区列表</span>
186
+ <span class="subtitle">supportedTimezones</span>
187
+ </a>
188
+ </li>
189
+ <li>
190
+ <a href="#hash26">
191
+ <span class="title">获取当前时区间差(分钟)</span>
192
+ <span class="subtitle">getTimezoneOffset()</span>
193
+ </a>
194
+ </li>
195
+ <li>
196
+ <a href="#hash27">
184
197
  <span class="title">返回当前时间戳(毫秒)</span>
185
198
  <span class="subtitle">now()</span>
186
199
  </a>
@@ -1123,6 +1136,28 @@
1123
1136
  </div>
1124
1137
  </div>
1125
1138
  <div id="hash25" class="box">
1139
+ <div class="c-hd">
1140
+ <p class="title">获取支持时区列表</p>
1141
+ <p class="subtitle">supportedTimezones</p>
1142
+ </div>
1143
+ <div class="c-bd">
1144
+ <p>支持的时区</p>
1145
+ <p>运行:datex.supportedTimezones</p>
1146
+ <p>返回:['Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ababa', 'Africa/Algiers', 'Africa/Asmera', 'Africa/Bamako',...]</p>
1147
+ </div>
1148
+ </div>
1149
+ <div id="hash26" class="box">
1150
+ <div class="c-hd">
1151
+ <p class="title">获取当前时区与UTC的时间差(分钟)</p>
1152
+ <p class="subtitle">getTimezoneOffset()</p>
1153
+ </div>
1154
+ <div class="c-bd">
1155
+ <p>全局设置</p>
1156
+ <p>运行:datex().switchTimezone("Europe/Berlin").getTimezoneOffset()</p>
1157
+ <p>返回:-60</p>
1158
+ </div>
1159
+ </div>
1160
+ <div id="hash27" class="box">
1126
1161
  <div class="c-hd">
1127
1162
  <p class="title">返回当前时间戳(毫秒)</p>
1128
1163
  <p class="subtitle">now()</p>
@@ -1165,28 +1200,6 @@
1165
1200
  $('.mod-menu').headroom({autoHide:false,scrollOffset:10,background:'transparent',autoFixed:false});
1166
1201
  </script>
1167
1202
  <script async defer src="https://cdn.bootcdn.net/ajax/libs/github-buttons/2.21.1/buttons.min.js"></script>
1168
- <script>
1169
- var _hmt = _hmt || [];
1170
- (function() {
1171
- var hm = document.createElement("script");
1172
- hm.src = "https://hm.baidu.com/hm.js?b86879c9cc57dd112fe1f7dd75206b82";
1173
- var s = document.getElementsByTagName("script")[0];
1174
- s.parentNode.insertBefore(hm, s);
1175
- })();
1176
- </script>
1177
- <script>
1178
- (function(){
1179
- var bp = document.createElement('script');
1180
- var curProtocol = window.location.protocol.split(':')[0];
1181
- if (curProtocol === 'https') {
1182
- bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
1183
- }
1184
- else {
1185
- bp.src = 'http://push.zhanzhang.baidu.com/push.js';
1186
- }
1187
- var s = document.getElementsByTagName("script")[0];
1188
- s.parentNode.insertBefore(bp, s);
1189
- })();
1190
- </script>
1203
+ <script type="text/javascript" src="https://passer-by.com/public/script/stat.js"></script>
1191
1204
  </body>
1192
1205
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datex.js",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "a datetime format library",
5
5
  "author": "HaoLe Zheng",
6
6
  "license": "MIT",
package/src/datex.js CHANGED
@@ -1,21 +1,24 @@
1
1
  let _langMap = {};
2
- _langMap['en-US'] = {
2
+ _langMap['en-us'] = {
3
3
  'MMM':['Jan.','Feb.','Mar.','Apr.','May.','Jun.','Jul.','Aug.','Sept.','Oct.','Nov.','Dec.'],
4
4
  'MMMM':['January','February','March','April','May','June','July','August','September','October','November','December'],
5
5
  'Do':['1st','2nd','3rd','4th','5th','6th','7th','8th','9th','10th','11th','12th','13th','14th','15th','16th','17th','18th','19th','20th','21st','22nd','23rd','24th','25th','26th','27th','28th','29th','30th','31st'],
6
6
  'WW':['Sun.','Mon.','Tues.','Wed.','Thur.','Fri.','Sat.'],
7
7
  'WWW':['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
8
8
  };
9
- _langMap['zh-CN'] = {
9
+ _langMap['zh-cn'] = {
10
10
  'MMM':['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
11
11
  'MMMM':['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
12
12
  'Do':['1日','2日','3日','4日','5日','6日','7日','8日','9日','10日','11日','12日','13日','14日','15日','16日','17日','18日','19日','20日','21日','22日','23日','24日','25日','26日','27日','28日','29日','30日','31日'],
13
13
  'WW':['周日','周一','周二','周三','周四','周五','周六'],
14
14
  'WWW':['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
15
15
  };
16
- let _lang = 'en-US';
16
+ let _lang = 'en-us';
17
17
  if(typeof self!='undefined'&&self.navigator){
18
- _lang = self.navigator.language;
18
+ _lang = self.navigator.language.toLowerCase();
19
+ if (!_langMap[_lang]) {
20
+ _lang = 'en-us';
21
+ }
19
22
  }
20
23
  let _timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
21
24
  let _offset = 0;
@@ -42,6 +45,7 @@ datex.switchLanguage = function(lang){
42
45
  return this;
43
46
  };
44
47
  datex.now = Date.now;
48
+ datex.supportedTimezones = typeof Intl!='undefined'&&Intl.supportedValuesOf?Intl.supportedValuesOf('timeZone'):[];
45
49
  datex.switchTimezone = function(timezone){
46
50
  _timezone = timezone;
47
51
  _offset = convertTimeZone(new Date('1970/1/1'),_timezone).getTime() - (new Date('1970/1/1')).getTime();
@@ -49,7 +53,9 @@ datex.switchTimezone = function(timezone){
49
53
  datex.getTimezone = function(){
50
54
  return _timezone;
51
55
  };
52
- datex.supportedTimezones = Intl.supportedValuesOf('timeZone');
56
+ datex.getTimezoneOffset = function(){
57
+ return (new Date).getTimezoneOffset() - _offset/60000;
58
+ };
53
59
 
54
60
  datex.prototype = {
55
61
  _date:null,
@@ -306,11 +312,12 @@ datex.prototype = {
306
312
  return this.get(unit)>startDate.get(unit)&&this.get(unit)<endDate.get(unit);
307
313
  },
308
314
  setLanguage(lang,data={}){
315
+ lang = lang.toLowerCase();
309
316
  this._langMap[lang] = Object.assign(this._langMap[lang]||{},data);
310
317
  return this;
311
318
  },
312
319
  switchLanguage(lang){
313
- this._lang = lang;
320
+ this._lang = lang.toLowerCase();
314
321
  return this;
315
322
  },
316
323
  switchTimezone(timezone){
@@ -322,7 +329,7 @@ datex.prototype = {
322
329
  return this._timezone||_timezone;
323
330
  },
324
331
  getTimezoneOffset(){
325
- return this.getTimezone() - (this._offset||_offset)/60000;
332
+ return this._date.getTimezoneOffset() - (this._offset||_offset)/60000;
326
333
  },
327
334
  isValid(){
328
335
  return !isNaN(this.getTime());
@@ -1,54 +1,54 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg width="1440px" height="448px" viewBox="0 0 1440 448" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <!-- Generator: Sketch 59.1 (86144) - https://sketch.com -->
4
- <title>编组 5备份</title>
5
- <desc>Created with Sketch.</desc>
6
- <defs>
7
- <linearGradient x1="-5.68700053%" y1="45.5298642%" x2="84.7892757%" y2="53.934985%" id="linearGradient-1">
8
- <stop stop-color="#FBFCFD" offset="0%"></stop>
9
- <stop stop-color="#F8FCFF" offset="100%"></stop>
10
- </linearGradient>
11
- <radialGradient cx="49.4552285%" cy="50%" fx="49.4552285%" fy="50%" r="94.8348304%" gradientTransform="translate(0.494552,0.500000),scale(0.311111,1.000000),rotate(90.000000),translate(-0.494552,-0.500000)" id="radialGradient-2">
12
- <stop stop-color="#FFFFFF" stop-opacity="0.5" offset="0%"></stop>
13
- <stop stop-color="#EDF6FF" stop-opacity="0.578179633" offset="100%"></stop>
14
- </radialGradient>
15
- <rect id="path-3" x="0" y="0" width="1440" height="448"></rect>
16
- <linearGradient x1="72.8463444%" y1="12.5451885%" x2="72.8463444%" y2="295.836589%" id="linearGradient-5">
17
- <stop stop-color="#FFFFFF" stop-opacity="0" offset="0%"></stop>
18
- <stop stop-color="#9FD7FF" stop-opacity="0.383058348" offset="100%"></stop>
19
- </linearGradient>
20
- <linearGradient x1="16.6159843%" y1="49.1386719%" x2="5.85340543%" y2="50.8613281%" id="linearGradient-6">
21
- <stop stop-color="#FFFFFF" stop-opacity="0" offset="0%"></stop>
22
- <stop stop-color="#F2F7FC" offset="100%"></stop>
23
- </linearGradient>
24
- <rect id="path-7" x="0" y="259" width="1440" height="189"></rect>
25
- <linearGradient x1="54.7550093%" y1="16.6478641%" x2="54.7550093%" y2="112.331979%" id="linearGradient-8">
26
- <stop stop-color="#FFFFFF" stop-opacity="0" offset="0%"></stop>
27
- <stop stop-color="#D2ECFF" stop-opacity="0.225387893" offset="100%"></stop>
28
- </linearGradient>
29
- </defs>
30
- <g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
31
- <g id="导航方案备份">
32
- <g id="编组-5备份">
33
- <g id="路径备份">
34
- <g id="蒙版">
35
- <g transform="translate(0.000000, 0.000000)">
36
- <mask id="mask-4" fill="white">
37
- <use xlink:href="#path-3"></use>
38
- </mask>
39
- <g>
40
- <use fill="url(#linearGradient-1)" xlink:href="#path-3"></use>
41
- <use fill="url(#radialGradient-2)" xlink:href="#path-3"></use>
42
- </g>
43
- <g id="矩形备份-32" mask="url(#mask-4)">
44
- <use fill="url(#linearGradient-5)" xlink:href="#path-7"></use>
45
- <use fill="url(#linearGradient-6)" xlink:href="#path-7"></use>
46
- </g>
47
- <rect id="矩形" fill="url(#linearGradient-8)" mask="url(#mask-4)" x="0" y="166" width="1440" height="282"></rect>
48
- </g>
49
- </g>
50
- </g>
51
- </g>
52
- </g>
53
- </g>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="1440px" height="448px" viewBox="0 0 1440 448" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 59.1 (86144) - https://sketch.com -->
4
+ <title>编组 5备份</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <defs>
7
+ <linearGradient x1="-5.68700053%" y1="45.5298642%" x2="84.7892757%" y2="53.934985%" id="linearGradient-1">
8
+ <stop stop-color="#FBFCFD" offset="0%"></stop>
9
+ <stop stop-color="#F8FCFF" offset="100%"></stop>
10
+ </linearGradient>
11
+ <radialGradient cx="49.4552285%" cy="50%" fx="49.4552285%" fy="50%" r="94.8348304%" gradientTransform="translate(0.494552,0.500000),scale(0.311111,1.000000),rotate(90.000000),translate(-0.494552,-0.500000)" id="radialGradient-2">
12
+ <stop stop-color="#FFFFFF" stop-opacity="0.5" offset="0%"></stop>
13
+ <stop stop-color="#EDF6FF" stop-opacity="0.578179633" offset="100%"></stop>
14
+ </radialGradient>
15
+ <rect id="path-3" x="0" y="0" width="1440" height="448"></rect>
16
+ <linearGradient x1="72.8463444%" y1="12.5451885%" x2="72.8463444%" y2="295.836589%" id="linearGradient-5">
17
+ <stop stop-color="#FFFFFF" stop-opacity="0" offset="0%"></stop>
18
+ <stop stop-color="#9FD7FF" stop-opacity="0.383058348" offset="100%"></stop>
19
+ </linearGradient>
20
+ <linearGradient x1="16.6159843%" y1="49.1386719%" x2="5.85340543%" y2="50.8613281%" id="linearGradient-6">
21
+ <stop stop-color="#FFFFFF" stop-opacity="0" offset="0%"></stop>
22
+ <stop stop-color="#F2F7FC" offset="100%"></stop>
23
+ </linearGradient>
24
+ <rect id="path-7" x="0" y="259" width="1440" height="189"></rect>
25
+ <linearGradient x1="54.7550093%" y1="16.6478641%" x2="54.7550093%" y2="112.331979%" id="linearGradient-8">
26
+ <stop stop-color="#FFFFFF" stop-opacity="0" offset="0%"></stop>
27
+ <stop stop-color="#D2ECFF" stop-opacity="0.225387893" offset="100%"></stop>
28
+ </linearGradient>
29
+ </defs>
30
+ <g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
31
+ <g id="导航方案备份">
32
+ <g id="编组-5备份">
33
+ <g id="路径备份">
34
+ <g id="蒙版">
35
+ <g transform="translate(0.000000, 0.000000)">
36
+ <mask id="mask-4" fill="white">
37
+ <use xlink:href="#path-3"></use>
38
+ </mask>
39
+ <g>
40
+ <use fill="url(#linearGradient-1)" xlink:href="#path-3"></use>
41
+ <use fill="url(#radialGradient-2)" xlink:href="#path-3"></use>
42
+ </g>
43
+ <g id="矩形备份-32" mask="url(#mask-4)">
44
+ <use fill="url(#linearGradient-5)" xlink:href="#path-7"></use>
45
+ <use fill="url(#linearGradient-6)" xlink:href="#path-7"></use>
46
+ </g>
47
+ <rect id="矩形" fill="url(#linearGradient-8)" mask="url(#mask-4)" x="0" y="166" width="1440" height="282"></rect>
48
+ </g>
49
+ </g>
50
+ </g>
51
+ </g>
52
+ </g>
53
+ </g>
54
54
  </svg>