aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilip Roberts2013-01-30 10:50:34 +0100
committerIgor Minar2013-02-07 01:32:04 -0800
commitb001c8ece5472626bf49cf82753e8ac1aafd2513 (patch)
tree6442b82191aae96039d6648c79f84ba16aa46559 /src
parentbec4435945d9a18eb6650caaca022da00fd7a1d4 (diff)
downloadangular.js-b001c8ece5472626bf49cf82753e8ac1aafd2513.tar.bz2
fix(date): invert timezone sign and always display sign
This commit fixes #1261 and #1532. This covers two separate issues: - Positive timezones were being formatted without a leading `+` resulting in a formatting string like: "HH:MM:ssZ" giving "12:13:141000" instead of "12:13:14+1000". Fixed by checking if timezone is > 0 and adding a leading "+". - Timezone output signs were inverted. mock.TzDate expects the timezone _offset_ as it's first argument, _not_ the timezone. This means that a mock.TzDate with a positive offset should result in a date string with a negative timezone, and vice-versa. Closes #1261, #1532
Diffstat (limited to 'src')
-rw-r--r--src/ng/filter/filters.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ng/filter/filters.js b/src/ng/filter/filters.js
index 4c7f2861..3459ef88 100644
--- a/src/ng/filter/filters.js
+++ b/src/ng/filter/filters.js
@@ -211,8 +211,12 @@ function dateStrGetter(name, shortForm) {
}
function timeZoneGetter(date) {
- var offset = date.getTimezoneOffset();
- return padNumber(offset / 60, 2) + padNumber(Math.abs(offset % 60), 2);
+ var zone = -1 * date.getTimezoneOffset();
+ var paddedZone = (zone >= 0) ? "+" : "";
+
+ paddedZone += padNumber(zone / 60, 2) + padNumber(Math.abs(zone % 60), 2);
+
+ return paddedZone;
}
function ampmGetter(date, formats) {
@@ -319,7 +323,7 @@ var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+
expect(binding("1288323623006 | date:'medium'")).
toMatch(/Oct 2\d, 2010 \d{1,2}:\d{2}:\d{2} (AM|PM)/);
expect(binding("1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'")).
- toMatch(/2010\-10\-2\d \d{2}:\d{2}:\d{2} \-?\d{4}/);
+ toMatch(/2010\-10\-2\d \d{2}:\d{2}:\d{2} (\-|\+)?\d{4}/);
expect(binding("'1288323623006' | date:'MM/dd/yyyy @ h:mma'")).
toMatch(/10\/2\d\/2010 @ \d{1,2}:\d{2}(AM|PM)/);
});