momentjs-rails 2.8.2 → 2.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c52d9a9458f87392ace0ff468405e8cb2d2c18d6
4
- data.tar.gz: 16a59a72e7d28ed4d00f46da515e3748f816ba34
3
+ metadata.gz: ead75ba3769a872adc3b513d4357c43406cd2215
4
+ data.tar.gz: ccf7ff4f26ff1537e102819d44d8bc8c0de3408a
5
5
  SHA512:
6
- metadata.gz: b110533fe90eb25d56a1ae2c5866c473a12ac0ebc6621ab665da8dd0adeaf0b65d6910e8a558837e6e077ab7604ef5c18824cb9e4cf2abff1d84422af6ae3c9b
7
- data.tar.gz: 48e085b765f04390daaa1d06415758547ad92eedf15b0ac801dbeebc99e1a67b683097ea1c9fc1df0586c532aedeb7a46f03b7b56c8cedcf5b764e60c7a33909
6
+ metadata.gz: cbdc519b366c35ae481c1cbae30e95db9591e80c09f7bbb8e162eb7956b8fee11708faf4b490defc01cb400dbd04574295a042adb057e5f08aa4e172fcf2408a
7
+ data.tar.gz: 54ca514cd991d5440902e5cc47e9621cedabb1c9baf17ef8ad3989e73edf227879c9bf06df81d7287b4d37d02e00488193f9286ae60c2f78a01e0b1f02a344f8
data/README.md CHANGED
@@ -24,7 +24,7 @@ If you want to include a localization file, also add the following directive:
24
24
 
25
25
  ## Versioning
26
26
 
27
- momentjs-rails 2.8.2 == Moment.js 2.8.2
27
+ momentjs-rails 2.8.3 == Moment.js 2.8.3
28
28
 
29
29
  Every attempt is made to mirror the currently shipping Momentum.js version number wherever possible.
30
30
  The major, minor, and patch version numbers will always represent the Momentum.js version. Should a gem
data/news.md CHANGED
@@ -1,3 +1,6 @@
1
+ ### Version 2.8.3 (2014-09-11)
2
+ - Updated to Moment.js to 2.8.3
3
+
1
4
  ### Version 2.8.2 (2014-09-11)
2
5
  - Updated to Moment.js to 2.8.2
3
6
 
@@ -8,7 +8,7 @@ class NavigationTest < ActionDispatch::IntegrationTest
8
8
 
9
9
  test 'momentjs response is for the expected version' do
10
10
  get 'assets/moment.js'
11
- assert_match(/VERSION = "2\.8\.2"/, @response.body)
11
+ assert_match(/VERSION = "2\.8\.3"/, @response.body)
12
12
  end
13
13
 
14
14
  test 'can access momentjs translation' do
@@ -1,5 +1,5 @@
1
1
  //! moment.js
2
- //! version : 2.8.2
2
+ //! version : 2.8.3
3
3
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
4
4
  //! license : MIT
5
5
  //! momentjs.com
@@ -10,7 +10,7 @@
10
10
  ************************************/
11
11
 
12
12
  var moment,
13
- VERSION = '2.8.2',
13
+ VERSION = '2.8.3',
14
14
  // the global-scope this is NOT the global object in Node.js
15
15
  globalScope = typeof global !== 'undefined' ? global : this,
16
16
  oldGlobalMoment,
@@ -1493,6 +1493,9 @@
1493
1493
  for (i = 0; i < config._f.length; i++) {
1494
1494
  currentScore = 0;
1495
1495
  tempConfig = copyConfig({}, config);
1496
+ if (config._useUTC != null) {
1497
+ tempConfig._useUTC = config._useUTC;
1498
+ }
1496
1499
  tempConfig._pf = defaultParsingFlags();
1497
1500
  tempConfig._f = config._f[i];
1498
1501
  makeDateFromStringAndFormat(tempConfig);
@@ -1557,6 +1560,14 @@
1557
1560
  }
1558
1561
  }
1559
1562
 
1563
+ function map(arr, fn) {
1564
+ var res = [], i;
1565
+ for (i = 0; i < arr.length; ++i) {
1566
+ res.push(fn(arr[i], i));
1567
+ }
1568
+ return res;
1569
+ }
1570
+
1560
1571
  function makeDateFromInput(config) {
1561
1572
  var input = config._i, matched;
1562
1573
  if (input === undefined) {
@@ -1568,7 +1579,9 @@
1568
1579
  } else if (typeof input === 'string') {
1569
1580
  makeDateFromString(config);
1570
1581
  } else if (isArray(input)) {
1571
- config._a = input.slice(0);
1582
+ config._a = map(input.slice(0), function (obj) {
1583
+ return parseInt(obj, 10);
1584
+ });
1572
1585
  dateFromConfig(config);
1573
1586
  } else if (typeof(input) === 'object') {
1574
1587
  dateFromObject(config);
@@ -2123,7 +2136,7 @@
2123
2136
  this._isUTC = false;
2124
2137
 
2125
2138
  if (keepLocalTime) {
2126
- this.add(this._d.getTimezoneOffset(), 'm');
2139
+ this.add(this._dateTzOffset(), 'm');
2127
2140
  }
2128
2141
  }
2129
2142
  return this;
@@ -2141,7 +2154,7 @@
2141
2154
  diff : function (input, units, asFloat) {
2142
2155
  var that = makeAs(input, this),
2143
2156
  zoneDiff = (this.zone() - that.zone()) * 6e4,
2144
- diff, output;
2157
+ diff, output, daysAdjust;
2145
2158
 
2146
2159
  units = normalizeUnits(units);
2147
2160
 
@@ -2152,11 +2165,12 @@
2152
2165
  output = ((this.year() - that.year()) * 12) + (this.month() - that.month());
2153
2166
  // adjust by taking difference in days, average number of days
2154
2167
  // and dst in the given months.
2155
- output += ((this - moment(this).startOf('month')) -
2156
- (that - moment(that).startOf('month'))) / diff;
2168
+ daysAdjust = (this - moment(this).startOf('month')) -
2169
+ (that - moment(that).startOf('month'));
2157
2170
  // same as above but with zones, to negate all dst
2158
- output -= ((this.zone() - moment(this).startOf('month').zone()) -
2159
- (that.zone() - moment(that).startOf('month').zone())) * 6e4 / diff;
2171
+ daysAdjust -= ((this.zone() - moment(this).startOf('month').zone()) -
2172
+ (that.zone() - moment(that).startOf('month').zone())) * 6e4;
2173
+ output += daysAdjust / diff;
2160
2174
  if (units === 'year') {
2161
2175
  output = output / 12;
2162
2176
  }
@@ -2265,18 +2279,33 @@
2265
2279
  },
2266
2280
 
2267
2281
  isAfter: function (input, units) {
2268
- units = typeof units !== 'undefined' ? units : 'millisecond';
2269
- return +this.clone().startOf(units) > +moment(input).startOf(units);
2282
+ units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
2283
+ if (units === 'millisecond') {
2284
+ input = moment.isMoment(input) ? input : moment(input);
2285
+ return +this > +input;
2286
+ } else {
2287
+ return +this.clone().startOf(units) > +moment(input).startOf(units);
2288
+ }
2270
2289
  },
2271
2290
 
2272
2291
  isBefore: function (input, units) {
2273
- units = typeof units !== 'undefined' ? units : 'millisecond';
2274
- return +this.clone().startOf(units) < +moment(input).startOf(units);
2292
+ units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
2293
+ if (units === 'millisecond') {
2294
+ input = moment.isMoment(input) ? input : moment(input);
2295
+ return +this < +input;
2296
+ } else {
2297
+ return +this.clone().startOf(units) < +moment(input).startOf(units);
2298
+ }
2275
2299
  },
2276
2300
 
2277
2301
  isSame: function (input, units) {
2278
- units = units || 'ms';
2279
- return +this.clone().startOf(units) === +makeAs(input, this).startOf(units);
2302
+ units = normalizeUnits(units || 'millisecond');
2303
+ if (units === 'millisecond') {
2304
+ input = moment.isMoment(input) ? input : moment(input);
2305
+ return +this === +input;
2306
+ } else {
2307
+ return +this.clone().startOf(units) === +makeAs(input, this).startOf(units);
2308
+ }
2280
2309
  },
2281
2310
 
2282
2311
  min: deprecate(
@@ -2316,7 +2345,7 @@
2316
2345
  input = input * 60;
2317
2346
  }
2318
2347
  if (!this._isUTC && keepLocalTime) {
2319
- localAdjust = this._d.getTimezoneOffset();
2348
+ localAdjust = this._dateTzOffset();
2320
2349
  }
2321
2350
  this._offset = input;
2322
2351
  this._isUTC = true;
@@ -2334,7 +2363,7 @@
2334
2363
  }
2335
2364
  }
2336
2365
  } else {
2337
- return this._isUTC ? offset : this._d.getTimezoneOffset();
2366
+ return this._isUTC ? offset : this._dateTzOffset();
2338
2367
  }
2339
2368
  return this;
2340
2369
  },
@@ -2438,10 +2467,15 @@
2438
2467
  // instance. Otherwise, it will return the locale configuration
2439
2468
  // variables for this instance.
2440
2469
  locale : function (key) {
2470
+ var newLocaleData;
2471
+
2441
2472
  if (key === undefined) {
2442
2473
  return this._locale._abbr;
2443
2474
  } else {
2444
- this._locale = moment.localeData(key);
2475
+ newLocaleData = moment.localeData(key);
2476
+ if (newLocaleData != null) {
2477
+ this._locale = newLocaleData;
2478
+ }
2445
2479
  return this;
2446
2480
  }
2447
2481
  },
@@ -2452,14 +2486,19 @@
2452
2486
  if (key === undefined) {
2453
2487
  return this.localeData();
2454
2488
  } else {
2455
- this._locale = moment.localeData(key);
2456
- return this;
2489
+ return this.locale(key);
2457
2490
  }
2458
2491
  }
2459
2492
  ),
2460
2493
 
2461
2494
  localeData : function () {
2462
2495
  return this._locale;
2496
+ },
2497
+
2498
+ _dateTzOffset : function () {
2499
+ // On Firefox.24 Date#getTimezoneOffset returns a floating point.
2500
+ // https://github.com/moment/moment/pull/1871
2501
+ return Math.round(this._d.getTimezoneOffset() / 15) * 15;
2463
2502
  }
2464
2503
  });
2465
2504
 
@@ -2657,19 +2696,21 @@
2657
2696
  var days, months;
2658
2697
  units = normalizeUnits(units);
2659
2698
 
2660
- days = this._days + this._milliseconds / 864e5;
2661
2699
  if (units === 'month' || units === 'year') {
2700
+ days = this._days + this._milliseconds / 864e5;
2662
2701
  months = this._months + daysToYears(days) * 12;
2663
2702
  return units === 'month' ? months : months / 12;
2664
2703
  } else {
2665
- days += yearsToDays(this._months / 12);
2704
+ // handle milliseconds separately because of floating point math errors (issue #1867)
2705
+ days = this._days + yearsToDays(this._months / 12);
2666
2706
  switch (units) {
2667
- case 'week': return days / 7;
2668
- case 'day': return days;
2669
- case 'hour': return days * 24;
2670
- case 'minute': return days * 24 * 60;
2671
- case 'second': return days * 24 * 60 * 60;
2672
- case 'millisecond': return days * 24 * 60 * 60 * 1000;
2707
+ case 'week': return days / 7 + this._milliseconds / 6048e5;
2708
+ case 'day': return days + this._milliseconds / 864e5;
2709
+ case 'hour': return days * 24 + this._milliseconds / 36e5;
2710
+ case 'minute': return days * 24 * 60 + this._milliseconds / 6e4;
2711
+ case 'second': return days * 24 * 60 * 60 + this._milliseconds / 1000;
2712
+ // Math.floor prevents floating point math errors here
2713
+ case 'millisecond': return Math.floor(days * 24 * 60 * 60 * 1000) + this._milliseconds;
2673
2714
  default: throw new Error('Unknown unit ' + units);
2674
2715
  }
2675
2716
  }
@@ -1,7 +1,8 @@
1
1
  // moment.js locale configuration
2
- // locale : Arabic (ar)
3
- // author : Abdel Said : https://github.com/abdelsaid
4
- // changes in months, weekdays : Ahmed Elkhatib
2
+ // Locale: Arabic (ar)
3
+ // Author: Abdel Said: https://github.com/abdelsaid
4
+ // Changes in months, weekdays: Ahmed Elkhatib
5
+ // Native plural forms: forabi https://github.com/forabi
5
6
 
6
7
  (function (factory) {
7
8
  if (typeof define === 'function' && define.amd) {
@@ -34,11 +35,42 @@
34
35
  '٨': '8',
35
36
  '٩': '9',
36
37
  '٠': '0'
37
- };
38
+ }, pluralForm = function (n) {
39
+ return n === 0 ? 0 : n === 1 ? 1 : n === 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
40
+ }, plurals = {
41
+ s : ['أقل من ثانية', 'ثانية واحدة', ['ثانيتان', 'ثانيتين'], '%d ثوان', '%d ثانية', '%d ثانية'],
42
+ m : ['أقل من دقيقة', 'دقيقة واحدة', ['دقيقتان', 'دقيقتين'], '%d دقائق', '%d دقيقة', '%d دقيقة'],
43
+ h : ['أقل من ساعة', 'ساعة واحدة', ['ساعتان', 'ساعتين'], '%d ساعات', '%d ساعة', '%d ساعة'],
44
+ d : ['أقل من يوم', 'يوم واحد', ['يومان', 'يومين'], '%d أيام', '%d يومًا', '%d يوم'],
45
+ M : ['أقل من شهر', 'شهر واحد', ['شهران', 'شهرين'], '%d أشهر', '%d شهرا', '%d شهر'],
46
+ y : ['أقل من عام', 'عام واحد', ['عامان', 'عامين'], '%d أعوام', '%d عامًا', '%d عام']
47
+ }, pluralize = function (u) {
48
+ return function (number, withoutSuffix, string, isFuture) {
49
+ var f = pluralForm(number),
50
+ str = plurals[u][pluralForm(number)];
51
+ if (f === 2) {
52
+ str = str[withoutSuffix ? 0 : 1];
53
+ }
54
+ return str.replace(/%d/i, number);
55
+ };
56
+ }, months = [
57
+ 'كانون الثاني يناير',
58
+ 'شباط فبراير',
59
+ 'آذار مارس',
60
+ 'نيسان أبريل',
61
+ 'أيار مايو',
62
+ 'حزيران يونيو',
63
+ 'تموز يوليو',
64
+ 'آب أغسطس',
65
+ 'أيلول سبتمبر',
66
+ 'تشرين الأول أكتوبر',
67
+ 'تشرين الثاني نوفمبر',
68
+ 'كانون الأول ديسمبر'
69
+ ];
38
70
 
39
71
  return moment.defineLocale('ar', {
40
- months : 'يناير/ كانون الثاني_فبراير/ شباط_مارس/ آذار_أبريل/ نيسان_مايو/ أيار_يونيو/ حزيران_يوليو/ تموز_أغسطس/ آب_سبتمبر/ أيلول_أكتوبر/ تشرين الأول_نوفمبر/ تشرين الثاني_ديسمبر/ كانون الأول'.split('_'),
41
- monthsShort : 'يناير/ كانون الثاني_فبراير/ شباط_مارس/ آذار_أبريل/ نيسان_مايو/ أيار_يونيو/ حزيران_يوليو/ تموز_أغسطس/ آب_سبتمبر/ أيلول_أكتوبر/ تشرين الأول_نوفمبر/ تشرين الثاني_ديسمبر/ كانون الأول'.split('_'),
72
+ months : months,
73
+ monthsShort : months,
42
74
  weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
43
75
  weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
44
76
  weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
@@ -57,27 +89,27 @@
57
89
  }
58
90
  },
59
91
  calendar : {
60
- sameDay: '[اليوم على الساعة] LT',
61
- nextDay: '[غدا على الساعة] LT',
62
- nextWeek: 'dddd [على الساعة] LT',
63
- lastDay: '[أمس على الساعة] LT',
64
- lastWeek: 'dddd [على الساعة] LT',
92
+ sameDay: '[اليوم عند الساعة] LT',
93
+ nextDay: '[غدًا عند الساعة] LT',
94
+ nextWeek: 'dddd [عند الساعة] LT',
95
+ lastDay: '[أمس عند الساعة] LT',
96
+ lastWeek: 'dddd [عند الساعة] LT',
65
97
  sameElse: 'L'
66
98
  },
67
99
  relativeTime : {
68
- future : 'في %s',
100
+ future : 'بعد %s',
69
101
  past : 'منذ %s',
70
- s : 'ثوان',
71
- m : 'دقيقة',
72
- mm : '%d دقائق',
73
- h : 'ساعة',
74
- hh : '%d ساعات',
75
- d : 'يوم',
76
- dd : '%d أيام',
77
- M : 'شهر',
78
- MM : '%d أشهر',
79
- y : 'سنة',
80
- yy : '%d سنوات'
102
+ s : pluralize('s'),
103
+ m : pluralize('m'),
104
+ mm : pluralize('m'),
105
+ h : pluralize('h'),
106
+ hh : pluralize('h'),
107
+ d : pluralize('d'),
108
+ dd : pluralize('d'),
109
+ M : pluralize('M'),
110
+ MM : pluralize('M'),
111
+ y : pluralize('y'),
112
+ yy : pluralize('y')
81
113
  },
82
114
  preparse: function (string) {
83
115
  return string.replace(/[۰-۹]/g, function (match) {
@@ -86,7 +86,7 @@
86
86
  weekdaysShort : 'ne_po_út_st_čt_pá_so'.split('_'),
87
87
  weekdaysMin : 'ne_po_út_st_čt_pá_so'.split('_'),
88
88
  longDateFormat : {
89
- LT: 'H.mm',
89
+ LT: 'H:mm',
90
90
  L : 'DD. MM. YYYY',
91
91
  LL : 'D. MMMM YYYY',
92
92
  LLL : 'D. MMMM YYYY LT',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: momentjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.2
4
+ version: 2.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Prior