]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
toString now returns a fixed format that looks like unix data 565/head 566/head
authorIskren Chernev <iskren.chernev@gmail.com>
Tue, 8 Jan 2013 05:30:03 +0000 (21:30 -0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Tue, 8 Jan 2013 05:30:03 +0000 (21:30 -0800)
This is actually fixing #475 -- toString on utc moments was returning
localized format. This commit fixes the issue and also makes sure that
toString will work uniformly on all browsers from now on.

moment.js
test/moment/create.js
test/moment/format.js

index b45633ba8ff37e83826966242175ecd6709fc940..1d9cbcf842c92e17267f8c4085b551691c0810b1 100644 (file)
--- a/moment.js
+++ b/moment.js
         },
 
         toString : function () {
-            return this._d.toString();
+            return this.format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ");
         },
 
         toDate : function () {
index 41defc75304deea8ba91155ce5a837007ee4c207..2be29b53d34c1e7c1df76bc434d36dc90f3586a1 100644 (file)
@@ -69,13 +69,6 @@ exports.create = {
         test.done();
     },
 
-    "string from Date.toString" : function(test) {
-        test.expect(1);
-        var str = (new Date()).toString();
-        test.equal(moment(str).toString(), str, "Parsing a string from Date.prototype.toString should match moment.fn.toString");
-        test.done();
-    },
-
     "string without format - json" : function(test) {
         test.expect(5);
         test.equal(moment("Date(1325132654000)").valueOf(), 1325132654000, "Date(1325132654000)");
index 0d336554489b1553d3c44404a6c8e13098c1dc89..769f26b014b3af40bda33abdfd49a9fce96b5d8c 100644 (file)
@@ -166,6 +166,14 @@ exports.format = {
             test.equal(iso, the, i + ": should be " + iso + ", but " + the);
         }
 
+        test.done();
+    },
+
+    "toString is just human readable format" : function(test) {
+        test.expect(1);
+
+        var b = moment(new Date(2009, 1, 5, 15, 25, 50, 125));
+        test.equal(b.toString(), b.format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'));
         test.done();
     }
 };