]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Merging in version 1.6.0
authorTim Wood <washwithcare@gmail.com>
Thu, 26 Apr 2012 16:36:12 +0000 (09:36 -0700)
committerTim Wood <washwithcare@gmail.com>
Thu, 26 Apr 2012 16:36:12 +0000 (09:36 -0700)
1  2 
moment.js
test/moment/create.js

diff --cc moment.js
index 4e1c5c672a784081fd1415e3cc4b7d0e5575dedc,4cc60e0fbbf60c8e0c3518d0c006b125374c1e3f..9242167a6a0b9fe9d17376c30bdc9add99502281
+++ b/moment.js
                  return currentSeconds;
              case 'ss' :
                  return leftZeroFill(currentSeconds, 2);
 -            case 'S' :
 -                return ~~ (currentMilliseconds / 100);
 -            case 'SS' :
 -                return leftZeroFill(~~(currentMilliseconds / 10), 2);
 -            case 'SSS' :
 -                return leftZeroFill(currentMilliseconds, 3);
              // TIMEZONE
-             case 'zz' :
-                 // depreciating 'zz' fall through to 'z'
-             case 'z' :
-                 return (m._d.toString().match(timezoneRegex) || [''])[0].replace(nonuppercaseLetters, '');
              case 'Z' :
                  return (currentZone < 0 ? '-' : '+') + leftZeroFill(~~(Math.abs(currentZone) / 60), 2) + ':' + leftZeroFill(~~(Math.abs(currentZone) % 60), 2);
              case 'ZZ' :
          return new Date(string);
      }
  
-     // helper function for _date.from() and _date.fromNow()
-     function substituteTimeAgo(string, number, withoutSuffix) {
+     // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
+     function substituteTimeAgo(string, number, withoutSuffix, isFuture) {
          var rt = moment.relativeTime[string];
          return (typeof rt === 'function') ?
 -            rt(number || 1, !!withoutSuffix, string, isFuture) :
 +            rt(number || 1, !!withoutSuffix, string) :
              rt.replace(/%d/i, number || 1);
      }
  
              return +this._d;
          },
  
-         'native' : function () {
-             return this._d;
++
+         unix : function () {
+             return Math.floor(+this._d / 1000);
          },
  
          toString : function () {
index 59cb748d623b472cb112ffd3e548cd6d3133cefe,88b520135020b7bc1e8631a0394a741a0d3189de..ff7487a5123e123d5366cfff31c7da3c71d2c387
@@@ -99,16 -118,33 +105,33 @@@ exports.create = 
          test.done();
      },
  
+     "string with format no separators" : function(test) {
+         moment.lang('en');
+         var a = [
+                 ['MMDDYYYY',          '12021999'],
+                 ['DDMMYYYY',          '12021999'],
+                 ['YYYYMMDD',          '19991202']
+             ],i;
+         test.expect(a.length);
+         for (i = 0; i < a.length; i++) {
+             test.equal(moment(a[i][1], a[i][0]).format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
+         }
+         
+         test.done();
+     },
      "string with format (timezone)" : function(test) {
          test.expect(8);
 -        test.equal(moment('5 -0700', 'H ZZ').toDate().getUTCHours(), 12, 'parse hours "5 -0700" ---> "H ZZ"');
 -        test.equal(moment('5 -07:00', 'H Z').toDate().getUTCHours(), 12, 'parse hours "5 -07:00" ---> "H Z"');
 -        test.equal(moment('5 -0730', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours "5 -0730" ---> "H ZZ"');
 -        test.equal(moment('5 -07:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours "5 -07:30" ---> "H Z"');
 -        test.equal(moment('5 +0100', 'H ZZ').toDate().getUTCHours(), 4, 'parse hours "5 +0100" ---> "H ZZ"');
 -        test.equal(moment('5 +01:00', 'H Z').toDate().getUTCHours(), 4, 'parse hours "5 +01:00" ---> "H Z"');
 -        test.equal(moment('5 +0130', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours "5 +0130" ---> "H ZZ"');
 -        test.equal(moment('5 +01:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours "5 +01:30" ---> "H Z"');
 +        test.equal(moment('5 -0700', 'H ZZ').native().getUTCHours(), 12, 'parse hours "5 -0700" ---> "H ZZ"');
 +        test.equal(moment('5 -07:00', 'H Z').native().getUTCHours(), 12, 'parse hours "5 -07:00" ---> "H Z"');
 +        test.equal(moment('5 -0730', 'H ZZ').native().getUTCMinutes(), 30, 'parse hours "5 -0730" ---> "H ZZ"');
 +        test.equal(moment('5 -07:30', 'H Z').native().getUTCMinutes(), 30, 'parse hours "5 -07:30" ---> "H Z"');
 +        test.equal(moment('5 +0100', 'H ZZ').native().getUTCHours(), 4, 'parse hours "5 +0100" ---> "H ZZ"');
 +        test.equal(moment('5 +01:00', 'H Z').native().getUTCHours(), 4, 'parse hours "5 +01:00" ---> "H Z"');
 +        test.equal(moment('5 +0130', 'H ZZ').native().getUTCMinutes(), 30, 'parse hours "5 +0130" ---> "H ZZ"');
 +        test.equal(moment('5 +01:30', 'H Z').native().getUTCMinutes(), 30, 'parse hours "5 +01:30" ---> "H Z"');
          test.done();
      },