Permalink
Browse files

Filter date('r') returns in UTC date format.

This is more correct tospec RFC2822, per php.net/date
  • Loading branch information...
1 parent d8eb460 commit 140e1c94d593a6baef0a0740a4a73674f392b512 @paularmstrong committed Dec 27, 2011
Showing with 5 additions and 3 deletions.
  1. +1 −1 docs/filters.md
  2. +1 −1 lib/dateformat.js
  3. +3 −1 tests/filters.test.js
View
@@ -250,7 +250,7 @@ Convert a valid date into a format as specified. Mostly conforms to [php.net's d
<tr>
<th scope="row"><code>r</code></th>
<td><a href="http://www.faqs.org/rfcs/rfc2822">RFC 2822</a> formatted date</td>
- <td><samp>Sat, 10 Sep 2011 14:34:30 -0700</samp></td>
+ <td><samp>Tue, 06 Sep 2011 16:05:02 GMT</samp></td>
</tr>
<tr>
<th scope="row"><code>U</code></th>
View
@@ -133,7 +133,7 @@ exports.c = function (input) {
return input.toISOString();
};
exports.r = function (input) {
- return input.toString();
+ return input.toUTCString();
};
exports.U = function (input) {
return input.getTime() / 1000;
View
@@ -37,6 +37,8 @@ exports.date = function (test) {
var date = new Date(2011, 8, 6, 9, 5, 2),
tpl = swig.compile('{{ d|date("d") }}');
+ date.setUTCHours(16);
+
function testFormat(format, expected) {
testFilter(test, 'date("' + format + '")', { v: date }, expected);
}
@@ -89,7 +91,7 @@ exports.date = function (test) {
// Full Date/Time
testFormat('c', '2011-09-06T16:05:02.000Z');
- testFormat('r', 'Tue Sep 06 2011 09:05:02 GMT-0700 (PDT)');
+ testFormat('r', 'Tue, 06 Sep 2011 16:05:02 GMT');
testFormat('U', '1315325102');
test.done();

0 comments on commit 140e1c9

Please sign in to comment.