forked from 0x2620/oxjs
calendar improvements (api, css, utc)
This commit is contained in:
parent
fda007f00d
commit
b18500d133
5 changed files with 253 additions and 194 deletions
21
source/Ox.js
21
source/Ox.js
|
|
@ -1445,6 +1445,27 @@ Ox.makeYear = function(date, utc) {
|
|||
return Ox.isDate(date) ? Ox.getFullYear(date, utc) : parseInt(date);
|
||||
};
|
||||
|
||||
|
||||
/*@
|
||||
Ox.parseDate(f) Takes a string ('YYYY-MM-DD HH:MM:SS') and returns a date
|
||||
str <s> string
|
||||
utc <b|false> If true, Date is UTC
|
||||
> +Ox.parseDate('1970', true)
|
||||
0
|
||||
@*/
|
||||
Ox.parseDate = function(str, utc) {
|
||||
var def = [, 1, 1, 0, 0, 0];
|
||||
val = /(\d+)-?(\d+)?-?(\d+)? ?(\d+)?:?(\d+)?:?(\d+)?/(str);
|
||||
val.shift();
|
||||
val = val.map(function(v, i) {
|
||||
return v || def[i];
|
||||
});
|
||||
val[1]--;
|
||||
return utc
|
||||
? new Date(Date.UTC(val[0], val[1], val[2], val[3], val[4], val[5]))
|
||||
: new Date(val[0], val[1], val[2], val[3], val[4], val[5])
|
||||
};
|
||||
|
||||
//@ Ox.setDate <f> Set the day of a date, optionally UTC
|
||||
// see Ox.setSeconds for source code
|
||||
//@ Ox.setDay <f> Set the weekday of a date, optionally UTC
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue