1
0
Fork 0
forked from 0x2620/oxjs

add Ox.isValidDate and Ox.isInvalidDate; fix Ox.makeDate

This commit is contained in:
rolux 2015-04-15 20:01:46 +01:00
commit fbc02301b5
2 changed files with 23 additions and 1 deletions

View file

@ -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)) {