dateplus: easy to modify date
NOTE
this lib add some function on Date
's prototype
supports
- ie8+
- nodejs
Examples
;// get a Date instance by splited number string (only for order by year month day hour minute second microsecond)var d=Date; // set month to 10d; // set day 1+1=2d // set hour 12-1=11d; // set hour 11-1=10 the samed; // short for d.getTime();//1412215200000d; // d.getTime(); with out microseconds// 1412215200d; // date format string// 2014-10-02 10:00:00:000d; // default date format string// Date.formats.default (yyyy-mm-dd hh:MM)// 2014-10-02 10:00d; // other short name for format// Date.formats.date='yyyy-mm-dd'// 2014-10-02d; // Date.formats.long='yyyy-mm-dd hh:MM:ss'// 2014-10-02 10:00:00d; // you can custom by modify Date.formatsDateformatsmicro='yyyy-mm-dd hh:MM:ss:SSS';// 2014-10-02 10:00:00:000d; // copy a instancevar d2=d; // chainvar d3=dy2014;
dictionary
main order is
- year
- month
- day
- hour
- minute
- second
- microsecond
unit name rule
- small unit Upper case (month Minute) (second microSecond)
var names= y:"FullYear" w:"Day" m:"Month" d:"Date" h:"Hours" M:"Minutes" s:"Seconds" S:"Milliseconds";
math
- bigest unit is day
var a=Date;var b=Date // means a - b = ?da;// 1 // also worksvar a=Date;var b=Date a;// 0.5a;// 12a;// 720a;// 43200a;// 43200000
parseCN
- get a Date instance by splited number string
- only for order by
year month day hour minute second microsecond
- set the rest to 0
// 2000-1-1 0:0:0:000Date; // 2000-2-1 0:0:0:000Date; // 2000-2-3 0:0:0:000Date; // every spliter are ok!// 2000-2-1 0:0:0:000Date;