From: Tim Wood Date: Sat, 17 Sep 2011 00:47:31 +0000 (-0700) Subject: switching to regex based format timezone X-Git-Tag: 0.6.0~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d277e1fa9aea1743f72a0e16c4aa2eae8f5b2ca3;p=thirdparty%2Fmoment.git switching to regex based format timezone --- diff --git a/underscore.date.js b/underscore.date.js index ae639a645..eef0d9180 100644 --- a/underscore.date.js +++ b/underscore.date.js @@ -67,9 +67,9 @@ currentHours = date.getHours(), currentMinutes = date.getMinutes(), currentSeconds = date.getSeconds(), - currentString = date.toString(), charactersToReplace = /(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?)/g, - nonuppercaseLetters = /[^A-Z]/g; + nonuppercaseLetters = /[^A-Z]/g, + timezoneRegex = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g; // check if the character is a format // return formatted string or non string. // @@ -161,11 +161,7 @@ case 'zz' : // depreciating 'zz' fall through to 'z' case 'z' : - a = currentString.indexOf('('); - if (a > -1) { - return currentString.slice(a + 1, currentString.indexOf(')')).replace(nonuppercaseLetters, ''); - } - return currentString.slice(currentString.indexOf(':')).replace(nonuppercaseLetters, ''); + return (date.toString().match(timezoneRegex) || [''])[0].replace(nonuppercaseLetters, ''); // DEFAULT default : return input.replace("\\", "");