forked from 0x2620/oxjs
add Ox.isValidDate and Ox.isInvalidDate; fix Ox.makeDate
This commit is contained in:
parent
d42b9c25fb
commit
fbc02301b5
2 changed files with 23 additions and 1 deletions
|
|
@ -257,7 +257,7 @@ Ox.makeDate <f> Takes a date, number or string, returns a date
|
|||
@*/
|
||||
Ox.makeDate = function(date) {
|
||||
// Safari 4/5 (<= 534.59.10) doesn't parse YYYY, YYYY-MM or YYYY-MM-DD
|
||||
if (Ox.isString(date)) {
|
||||
if (Ox.isString(date) && Ox.isInvalidDate(new Date(date))) {
|
||||
if (/^\d{4}$/.test(date)) {
|
||||
date += '-01-01';
|
||||
} else if (/^\d{4}-\d{2}$/.test(date)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue