From 26681d7e395f7f184c59e40ffe030fe8085cae90 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Sun, 10 Jun 2012 10:27:06 +0000 Subject: [PATCH] Ox.formatDateRangeDuration: avoid infinite loop when passing a start date that cannot be parsed --- source/Ox/js/Format.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/Ox/js/Format.js b/source/Ox/js/Format.js index 212586bd..dfbe46f5 100644 --- a/source/Ox/js/Format.js +++ b/source/Ox/js/Format.js @@ -422,13 +422,13 @@ Ox.formatDateRangeDuration 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,