datex.js 1.0.1 → 1.0.2

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.1
2
+ * datex.js v1.0.2
3
3
  * a datetime format library
4
4
  * https://passer-by.com/datex/
5
5
  *
@@ -10,4 +10,4 @@
10
10
  *
11
11
  * Created on: 2023-04-13
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"],W:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],w:["Sun.","Mon.","Tues.","Wed.","Thur.","Fri.","Sat."]},"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日"],W:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],w:["周日","周一","周二","周三","周四","周五","周六"]}},e=t["en-US"];"undefined"!=typeof self&&self.navigator&&(e=t[self.navigator.language]);const n=["year","month","day","hour","minute","second","millsecond"];function i(){return new i.prototype.init(...arguments)}function r(t){return t instanceof i?t:i(t)}return i.prototype={_date:null,init:function(){return arguments.length>=3&&arguments[1]--,this._date=new Date(...arguments),this},getTime(){return this._date.getTime()},getUnix(){return~~(this._date.getTime()/1e3)},clone(){return i(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 n.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(t="YYYY-MM-DD HH:mm:ss"){let n=this._date,i=this.toObject(),r=n.toTimeString().match(/GMT([\+\-])(\d{2})(\d{2})/),s={YYYY:""+i.year,YY:(""+i.year).padStart(2,"0"),MM:(""+i.month).padStart(2,"0"),M:""+i.month,DD:(""+i.day).padStart(2,"0"),D:""+i.day,HH:(""+i.hour).padStart(2,"0"),H:""+i.hour,hh:(""+i.hour%12).padStart(2,"0"),h:""+i.hour%12,mm:(""+i.minute).padStart(2,"0"),m:""+i.minute,ss:(""+i.second).padStart(2,"0"),s:""+i.second,S:""+~~(i.millsecond%1e3/100),SS:""+~~(i.millsecond%1e3/10),SSS:""+i.millsecond%1e3,Z:r[1]+r[2]+":"+r[3],ZZ:r[1]+r[2]+r[3],A:["AM","PM"][~~(i.hour/12)],a:["am","pm"][~~(i.hour/12)],X:~~(i.timestamp/1e3),x:i.timestamp,Q:""+~~(i.month/3)};return s.MMM=e.MMM[i.month-1],s.MMMM=e.MMMM[i.month-1],s.Do=e.Do[i.day-1],s.W=e.W[i.week],s.w=e.w[i.week],t.replace(/Y+|M+|D+|H+|h+|m+|s+|S+|Z+|Do|A|a|X|x|Q|W|w/g,(function(t){return s[t]||""}))},startOf(t){let e=this.toObject(),r=null,s=n.indexOf(t)+1,a=this.toArray(),h=[1970,1,1,0,0,0,0].slice(s);return a.splice(s,h.length,...h),r="timestamp"==t?this.clone():"week"==t?i(e.year,e.month,e.day-e.week,0,0,0,0):i(...a),r},endOf(t){return this.startOf(t).change(t,"week"==t?7:1).change("millsecond",-1)},diffWith(t,e){if(!(t=r(t)).isValid())return!1;let i={day:864e5,hour:36e5,minute:6e4,second:1e3,millsecond:1,timestamp:1},s=this.getTime()-t.getTime(),a=0;if(e){if(i[e])a=~~(s/i[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(),i={};return n.forEach((function(n){i[n]=e.diffWith(t,n),e.set(n,t.get(n))})),i}},isBefore(t,e="timestamp"){return t=r(t),this.get(e)<t.get(e)},isAfter(t,e="timestamp"){return t=r(t),this.get(e)>t.get(e)},isSame(t,e="timestamp"){return t=r(t),this.get(e)==t.get(e)},isBetween(t,e,n="timestamp"){return t=r(t),e=r(e),this.get(n)>t.get(n)&&this.get(n)<e.get(n)},isValid(){return!isNaN(this.getTime())}},i.prototype.init.prototype=i.prototype,i}));
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"],W:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],w:["Sun.","Mon.","Tues.","Wed.","Thur.","Fri.","Sat."]},"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日"],W:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],w:["周日","周一","周二","周三","周四","周五","周六"]}},e=t["en-US"];"undefined"!=typeof self&&self.navigator&&(e=t[self.navigator.language]);const n=["year","month","day","hour","minute","second","millsecond"],r=[1970,1,1,0,0,0,0];function a(...t){return new a.prototype.init(...t)}function i(t){return t instanceof a?t:a(t)}return a.prototype={_date:null,init:function(...t){var e;return t.length?(Array.isArray(t[0])?t=r.map(((e,n)=>t[0][n]||e)):null==(e=t[0])||"object"!=typeof e&&"function"!=typeof e||(t=r.map(((e,r)=>t[0][n[r]]||e))),t.length>=3&&t[1]--,this._date=new Date(...t)):this._date=new Date,this},getTime(){return this._date.getTime()},getUnix(){return~~(this._date.getTime()/1e3)},clone(){return a(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 n.map((e=>t[e]))},toString(){return this._date.toString()},toISOString(){return this._date.toISOString()},set(t,e){let n=this._date,r=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(r.day-r.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(t="YYYY-MM-DD HH:mm:ss"){let n=this._date,r=this.toObject(),a=n.toTimeString().match(/GMT([\+\-])(\d{2})(\d{2})/),i={YYYY:""+r.year,YY:(""+r.year).padStart(2,"0"),MM:(""+r.month).padStart(2,"0"),M:""+r.month,DD:(""+r.day).padStart(2,"0"),D:""+r.day,HH:(""+r.hour).padStart(2,"0"),H:""+r.hour,hh:(""+r.hour%12).padStart(2,"0"),h:""+r.hour%12,mm:(""+r.minute).padStart(2,"0"),m:""+r.minute,ss:(""+r.second).padStart(2,"0"),s:""+r.second,S:""+~~(r.millsecond%1e3/100),SS:""+~~(r.millsecond%1e3/10),SSS:""+r.millsecond%1e3,Z:a[1]+a[2]+":"+a[3],ZZ:a[1]+a[2]+a[3],A:["AM","PM"][~~(r.hour/12)],a:["am","pm"][~~(r.hour/12)],X:~~(r.timestamp/1e3),x:r.timestamp,Q:""+~~(r.month/3)};return i.MMM=e.MMM[r.month-1],i.MMMM=e.MMMM[r.month-1],i.Do=e.Do[r.day-1],i.W=e.W[r.week],i.w=e.w[r.week],t.replace(/Y+|M+|D+|H+|h+|m+|s+|S+|Z+|Do|A|a|X|x|Q|W|w/g,(function(t){return i[t]||""}))},startOf(t){let e=this.toObject(),i=null,s=n.indexOf(t)+1,o=this.toArray(),h=r.slice(s);return o.splice(s,h.length,...h),i="timestamp"==t?this.clone():"week"==t?a(e.year,e.month,e.day-e.week,0,0,0,0):a(...o),i},endOf(t){return this.startOf(t).change(t,"week"==t?7:1).change("millsecond",-1)},diffWith(t,e){if(!(t=i(t)).isValid())return!1;let r={day:864e5,hour:36e5,minute:6e4,second:1e3,millsecond:1},a=this.getTime()-t.getTime(),s=0;if(e){if(r[e])s=~~(a/r[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(),r={};return n.forEach((function(n){r[n]=e.diffWith(t,n),e.set(n,t.get(n))})),r}},isBefore(t,e="timestamp"){return t=i(t),this.get(e)<t.get(e)},isAfter(t,e="timestamp"){return t=i(t),this.get(e)>t.get(e)},isSame(t,e="timestamp"){return t=i(t),this.get(e)==t.get(e)},isBetween(t,e,n="timestamp"){return t=i(t),e=i(e),this.get(n)>t.get(n)&&this.get(n)<e.get(n)},isValid(){return!isNaN(this.getTime())}},a.prototype.init.prototype=a.prototype,a}));
package/index.html CHANGED
@@ -29,6 +29,12 @@
29
29
  <div class="mod-menu">
30
30
  <div class="bd">
31
31
  <ul>
32
+ <li>
33
+ <a href="#hash0">
34
+ <span class="title">初始化</span>
35
+ <span class="subtitle">datex</span>
36
+ </a>
37
+ </li>
32
38
  <li>
33
39
  <a href="#hash1">
34
40
  <span class="title">返回时间戳(毫秒)</span>
@@ -144,7 +150,7 @@
144
150
  </a>
145
151
  </li>
146
152
  <li>
147
- <a href="#has20">
153
+ <a href="#hash20">
148
154
  <span class="title">是否为有效对象</span>
149
155
  <span class="subtitle">isValid</span>
150
156
  </a>
@@ -171,6 +177,29 @@
171
177
  <p><a class="btn" href="https://passer-by.com/datex/dist/datex.min.js" target="_blank">获取脚本</a></p>
172
178
  </div>
173
179
  <div class="bd">
180
+ <div id="hash0" class="box">
181
+ <div class="c-hd">
182
+ <p class="title">初始化</p>
183
+ <p class="subtitle">datex(dateStr|Array|Object|)</p>
184
+ </div>
185
+ <div class="c-bd">
186
+ <p>通过多个参数初始化</p>
187
+ <p>运行:datex(2018,8,8)</p>
188
+ <br>
189
+ <p>通过时间字符串初始化</p>
190
+ <p>运行:datex('2018-08-08')</p>
191
+ <p>运行:datex('2018-04-04T16:00:00.000Z')</p>
192
+ <br>
193
+ <p>通过时间对象初始化</p>
194
+ <p>运行:datex({year:2008,month:8,day:8,hour:8,minute:0,second:0})</p>
195
+ <br>
196
+ <p>通过时间数组初始化</p>
197
+ <p>运行:datex([2018,8,8,8,8,0])</p>
198
+ <br>
199
+ <p>无参数初始化</p>
200
+ <p>运行:datex()</p>
201
+ </div>
202
+ </div>
174
203
  <div id="hash1" class="box">
175
204
  <div class="c-hd">
176
205
  <p class="title">返回时间戳(毫秒)</p>
@@ -744,14 +773,6 @@
744
773
  <td>millsecond</td>
745
774
  <td>毫秒</td>
746
775
  </tr>
747
- <tr>
748
- <td>timestamp</td>
749
- <td>时间戳</td>
750
- </tr>
751
- <tr>
752
- <td>week</td>
753
- <td>周几</td>
754
- </tr>
755
776
  </tbody>
756
777
  </table>
757
778
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datex.js",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "a datetime format library",
5
5
  "author": "HaoLe Zheng",
6
6
  "license": "MIT",
package/src/datex.js CHANGED
@@ -17,22 +17,35 @@ let language = langMap['en-US'];
17
17
  if(typeof self!='undefined'&&self.navigator){
18
18
  language = langMap[self.navigator.language];
19
19
  }
20
- const timeList = ['year','month','day','hour','minute','second','millsecond'];
20
+ const period = ['year','month','day','hour','minute','second','millsecond'];
21
+ const initTime = [1970,1,1,0,0,0,0];
21
22
 
22
- function datex(){
23
- return new datex.prototype.init(...arguments);
23
+ function datex(...argu){
24
+ return new datex.prototype.init(...argu);
24
25
  }
25
26
  function getInstance(that){
26
27
  return that instanceof datex?that:datex(that);
27
28
  }
29
+ function isObject(value){
30
+ return value != null && (typeof value == 'object' || typeof value == 'function');
31
+ }
28
32
 
29
33
  datex.prototype = {
30
34
  _date:null,
31
- init:function(){
32
- if(arguments.length>=3){
33
- arguments[1]--;
35
+ init:function(...argu){
36
+ if(!argu.length){
37
+ this._date = new Date();
38
+ }else{
39
+ if(Array.isArray(argu[0])){
40
+ argu = initTime.map((value,index)=>(argu[0][index]||value));
41
+ }else if(isObject(argu[0])){
42
+ argu = initTime.map((value,index)=>(argu[0][period[index]]||value));
43
+ }
44
+ if(argu.length>=3){
45
+ argu[1]--;
46
+ }
47
+ this._date = new Date(...argu);
34
48
  }
35
- this._date = new Date(...arguments);
36
49
  return this;
37
50
  },
38
51
  getTime(){
@@ -63,7 +76,7 @@ datex.prototype = {
63
76
  },
64
77
  toArray(){
65
78
  let $ = this.toObject();
66
- return timeList.map(name=>$[name]);
79
+ return period.map(name=>$[name]);
67
80
  },
68
81
  toString(){
69
82
  return this._date.toString();
@@ -155,9 +168,9 @@ datex.prototype = {
155
168
  startOf(unit){
156
169
  let $ = this.toObject();
157
170
  let that = null;
158
- let index = timeList.indexOf(unit)+1;
171
+ let index = period.indexOf(unit)+1;
159
172
  let dateSet = this.toArray();
160
- let initSet = [1970,1,1,0,0,0,0].slice(index);
173
+ let initSet = initTime.slice(index);
161
174
  dateSet.splice(index,initSet.length,...initSet);
162
175
  if(unit=='timestamp'){
163
176
  that = this.clone();
@@ -181,8 +194,7 @@ datex.prototype = {
181
194
  'hour':3.6e6,
182
195
  'minute':6e4,
183
196
  'second':1000,
184
- 'millsecond':1,
185
- 'timestamp':1
197
+ 'millsecond':1
186
198
  };
187
199
  let timestamp = this.getTime()-that.getTime();
188
200
  let value = 0;
@@ -210,7 +222,7 @@ datex.prototype = {
210
222
  }else{
211
223
  let clone = this.clone();
212
224
  let hash = {};
213
- timeList.forEach(function(unit){
225
+ period.forEach(function(unit){
214
226
  hash[unit] = clone.diffWith(that,unit);
215
227
  clone.set(unit,that.get(unit));
216
228
  });
@@ -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>
package/test/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
  var test = require('tape');
3
- var DateX = require('..');
3
+ var datex = require('..');
4
4
 
5
5
  test('[Test]', function (t) {
6
- t.deepEqual(DateX('2008-08-08').getTime(),1218153600000);
7
- t.deepEqual(DateX(2022,10,1).format('YYYY年MM月DD日'),'2022年10月01日');
8
- t.deepEqual(DateX(2022,10,1).set('year',2020).format(),'2020-10-01 00:00:00');
9
- t.deepEqual(DateX(2022,10,1).change('year',1).format(),'2023-10-01 00:00:00');
10
- t.deepEqual(DateX(2022,10,10).startOf('month').format(),'2022-10-01 00:00:00');
11
- t.deepEqual(DateX(2022,10,10).endOf('month').format(),'2022-10-31 23:59:59');
12
- t.deepEqual(DateX(2008,8,8,23,45,45).get('hour'),23);
13
- t.deepEqual(DateX('1949-10-01').diffWith('2022-12-01','month'),-878);
6
+ t.deepEqual(datex('2008-08-08').getTime(),1218153600000);
7
+ t.deepEqual(datex(2022,10,1).format('YYYY年MM月DD日'),'2022年10月01日');
8
+ t.deepEqual(datex(2022,10,1).set('year',2020).format(),'2020-10-01 00:00:00');
9
+ t.deepEqual(datex(2022,10,1).change('year',1).format(),'2023-10-01 00:00:00');
10
+ t.deepEqual(datex(2022,10,10).startOf('month').format(),'2022-10-01 00:00:00');
11
+ t.deepEqual(datex(2022,10,10).endOf('month').format(),'2022-10-31 23:59:59');
12
+ t.deepEqual(datex(2008,8,8,23,45,45).get('hour'),23);
13
+ t.deepEqual(datex('1949-10-01').diffWith('2022-12-01','month'),-878);
14
14
  t.end();
15
15
  });