Ox.formatDateRangeDuration: avoid infinite loop when passing a start date that cannot be parsed

This commit is contained in:
rlx 2012-06-10 10:27:06 +00:00
parent 92bfb38caf
commit 26681d7e39

View file

@ -422,13 +422,13 @@ Ox.formatDateRangeDuration <f> Formats the duration of a date range as a string
Ox.formatDateRangeDuration = function(start, end, utc) {
end = end || Ox.formatDate(new Date(), '%Y-%m-%d');
var date = Ox.parseDate(start, utc),
dates = [start, end].map(function(str) {
return Ox.parseDate(str, utc);
dates = [start, end].map(function(string) {
return Ox.parseDate(string, utc);
}),
keys = ['year', 'month', 'day', 'hour', 'minute', 'second'],
parts = ['FullYear', 'Month', 'Date', 'Hours', 'Minutes', 'Seconds'],
values = [];
keys.forEach(function(key, i) {
date && keys.forEach(function(key, i) {
while (true) {
if (key == 'month') {
// set the day to the same day in the next month,