diff --git a/source/Ox/js/Date.js b/source/Ox/js/Date.js index a96283e2..4dee0db2 100644 --- a/source/Ox/js/Date.js +++ b/source/Ox/js/Date.js @@ -247,15 +247,23 @@ Ox.makeDate Takes a date, number or string, returns a date '01/01/1970' > Ox.formatDate(Ox.makeDate('1970-01-01'), '%Y-%m-%d') '1970-01-01' + > Ox.formatDate(Ox.makeDate('1970'), '%Y') + '1970' + > Ox.formatDate(Ox.makeDate('1970-05'), '%Y-%m') + '1970-05' @*/ Ox.makeDate = function(date) { + //Safari 4/5 does not parse YYYY, YYYY-MM or YYYY-MM-DD as date + if ($.browser.safari && $.browser.version <= '534.59.10' && Ox.isString(date)) { + if (/^\d{4}$/.test(date)) { + date += '-01-01'; + } else if (/^\d{4}-\d{2}$/.test(date)) { + date += '-01'; + } + date = date.replace(/-/g, '/'); + } // if date is a date, new Date(date) makes a clone - return Ox.isUndefined(date) ? new Date() : new Date( - //Safari 4/5 does not understand YYYY-MM-DD format - $.browser.safari && $.browser.version <= '534.59.10' && Ox.isString(date) - ? date.replace(/-/g, '/') - : date - ); + return Ox.isUndefined(date) ? new Date() : new Date(date); }; /*@