]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
allow initializing with unix timestamp as integer 930/head
authorKlaus Jrgensen <klaus@blackwoodseven.com>
Wed, 17 Jul 2013 20:02:39 +0000 (22:02 +0200)
committerKlaus Jrgensen <klaus@blackwoodseven.com>
Wed, 17 Jul 2013 20:02:39 +0000 (22:02 +0200)
moment.js
test/moment/format.js

index c1673c1272832c9176923f2d58dce8c3bb7c4535..02bb1ddeddf52a533172960c0e63bedaffdb0d9e 100644 (file)
--- a/moment.js
+++ b/moment.js
     function makeDateFromStringAndFormat(config) {
         // This array is used to make a Date, either with `new Date` or `Date.UTC`
         var tokens = config._f.match(formattingTokens),
-            string = config._i,
+            string = '' + config._i,
             i, parsedInput;
 
         config._a = [];
index 6408bb60e6e979a67233dab61f82d0b644717379..1265a59448bc6223a770f134b46b26dc7b204cd7 100644 (file)
@@ -88,7 +88,7 @@ exports.format = {
     },
 
     "unix timestamp" : function (test) {
-        test.expect(4);
+        test.expect(5);
 
         var m = moment('1234567890.123', 'X');
         test.equals(m.format('X'), '1234567890', 'unix timestamp without milliseconds');
@@ -96,6 +96,9 @@ exports.format = {
         test.equals(m.format('X.SS'), '1234567890.12', 'unix timestamp with centiseconds');
         test.equals(m.format('X.SSS'), '1234567890.123', 'unix timestamp with milliseconds');
 
+        m = moment(1234567890.123, 'X');
+        test.equals(m.format('X'), '1234567890', 'unix timestamp as integer');
+        
         test.done();
     },