Add work around for YYYY and YYYY-MM dates for Safari, fixes #2329
This commit is contained in:
parent
48ce6fc101
commit
ec3a077c2e
1 changed files with 14 additions and 6 deletions
|
@ -247,15 +247,23 @@ Ox.makeDate <f> 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);
|
||||
};
|
||||
|
||||
/*@
|
||||
|
|
Loading…
Reference in a new issue