Skip to content

Commit

Permalink
Merge branch 'develop' into my-develop
Browse files Browse the repository at this point in the history
* develop:
  Added Gujarati locale for moment (moment#4004)
  Add bambara language. (moment#4001)
  NL and BE locale weekDaysMin should not be capitalized, updated to lowercase. (moment#3961)
  moment#1428: Updated Danish 'L' dateformat to use dots rather than slashes, aligning with article from DSN. (moment#3945)
  update travis to only test back to node 4
  jsnext:main -> module (moment#3904)
  Fix localeData months on Greek (moment#3868)
  Fix moment#4060: bundle.generate returns a Promise now
  compute monthDiff only for the type that needs it
  convert long ternary operator to switch for easier readability
  Changed setter check behavior to use isNaN() for checking whether an input is a valid value
  Removed unwarranted spaces, changed illegal quotes
  Added semicolon to helper
  Added new line in helper file
  Added helper 'isNumeric' to test values for validity in setters
  Update for  check,
  Added comment as requested in: moment#3504
  Fix for conditional in src/lib/units/offset.js:164 - I interpreted this is as simply not catching  being a falsy (but assumedly valid) time zone modifier (_tzm?) of 0
  • Loading branch information
Bofanda authored and Bofanda committed Aug 3, 2017
2 parents 6b76502 + 8919a98 commit 1d393b7
Show file tree
Hide file tree
Showing 20 changed files with 662 additions and 30 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
language: node_js
node_js:
- "node"
- "0.12"
- "7"
- "6"
- "5"
- "4"
sudo: false

env:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"ender"
],
"main": "./moment.js",
"jsnext:main": "./src/moment.js",
"module": "./src/moment.js",
"typings": "./moment.d.ts",
"engines": {
"node": "*"
Expand Down
26 changes: 11 additions & 15 deletions src/lib/moment/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,18 @@ export function diff (input, units, asFloat) {

units = normalizeUnits(units);

if (units === 'year' || units === 'month' || units === 'quarter') {
output = monthDiff(this, that);
if (units === 'quarter') {
output = output / 3;
} else if (units === 'year') {
output = output / 12;
}
} else {
delta = this - that;
output = units === 'second' ? delta / 1e3 : // 1000
units === 'minute' ? delta / 6e4 : // 1000 * 60
units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
delta;
switch (units) {
case 'year': output = monthDiff(this, that) / 12; break;
case 'month': output = monthDiff(this, that); break;
case 'quarter': output = monthDiff(this, that) / 3; break;
case 'second': output = (this - that) / 1e3; break; // 1000
case 'minute': output = (this - that) / 6e4; break; // 1000 * 60
case 'hour': output = (this - that) / 36e5; break; // 1000 * 60 * 60
case 'day': output = (this - that - zoneDelta) / 864e5; break; // 1000 * 60 * 60 * 24, negate dst
case 'week': output = (this - that - zoneDelta) / 6048e5; break; // 1000 * 60 * 60 * 24 * 7, negate dst
default: output = this - that;
}

return asFloat ? output : absFloor(output);
}

Expand Down
3 changes: 1 addition & 2 deletions src/lib/moment/get-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getPrioritizedUnits } from '../units/priorities';
import { hooks } from '../utils/hooks';
import isFunction from '../utils/is-function';


export function makeGetSet (unit, keepTime) {
return function (value) {
if (value != null) {
Expand All @@ -22,7 +21,7 @@ export function get (mom, unit) {
}

export function set (mom, unit, value) {
if (mom.isValid()) {
if (mom.isValid() && !isNaN(value)) {
mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/lib/utils/is-numeric.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default function isNumeric(val) {
var _val = +val;
return (val !== val + 1) && //infinity check
(_val === +val) && //Cute coercion check
(typeof val !== 'object'); //Array/object check
}
49 changes: 49 additions & 0 deletions src/locale/bm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//! moment.js locale configuration
//! locale : Bambara [bm]
//! author : Estelle Comment : https://github.com/estellecomment
// Language contact person : Abdoufata Kane : https://github.com/abdoufata

import moment from '../moment';

export default moment.defineLocale('bm', {
months : 'Zanwuyekalo_Fewuruyekalo_Marisikalo_Awirilikalo_Mɛkalo_Zuwɛnkalo_Zuluyekalo_Utikalo_Sɛtanburukalo_ɔkutɔburukalo_Nowanburukalo_Desanburukalo'.split('_'),
monthsShort : 'Zan_Few_Mar_Awi_Mɛ_Zuw_Zul_Uti_Sɛt_ɔku_Now_Des'.split('_'),
weekdays : 'Kari_Ntɛnɛn_Tarata_Araba_Alamisa_Juma_Sibiri'.split('_'),
weekdaysShort : 'Kar_Ntɛ_Tar_Ara_Ala_Jum_Sib'.split('_'),
weekdaysMin : 'Ka_Nt_Ta_Ar_Al_Ju_Si'.split('_'),
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
L : 'DD/MM/YYYY',
LL : 'MMMM [tile] D [san] YYYY',
LLL : 'MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm',
LLLL : 'dddd MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm'
},
calendar : {
sameDay : '[Bi lɛrɛ] LT',
nextDay : '[Sini lɛrɛ] LT',
nextWeek : 'dddd [don lɛrɛ] LT',
lastDay : '[Kunu lɛrɛ] LT',
lastWeek : 'dddd [tɛmɛnen lɛrɛ] LT',
sameElse : 'L'
},
relativeTime : {
future : '%s kɔnɔ',
past : 'a bɛ %s bɔ',
s : 'sanga dama dama',
m : 'miniti kelen',
mm : 'miniti %d',
h : 'lɛrɛ kelen',
hh : 'lɛrɛ %d',
d : 'tile kelen',
dd : 'tile %d',
M : 'kalo kelen',
MM : 'kalo %d',
y : 'san kelen',
yy : 'san %d'
},
week : {
dow : 1, // Monday is the first day of the week.
doy : 4 // The week that contains Jan 4th is the first week of the year.
}
});
2 changes: 1 addition & 1 deletion src/locale/da.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default moment.defineLocale('da', {
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
L : 'DD/MM/YYYY',
L : 'DD.MM.YYYY',
LL : 'D. MMMM YYYY',
LLL : 'D. MMMM YYYY HH:mm',
LLLL : 'dddd [d.] D. MMMM YYYY [kl.] HH:mm'
Expand Down
2 changes: 1 addition & 1 deletion src/locale/el.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default moment.defineLocale('el', {
months : function (momentToFormat, format) {
if (!momentToFormat) {
return this._monthsNominativeEl;
} else if (/D/.test(format.substring(0, format.indexOf('MMMM')))) { // if there is a day number before 'MMMM'
} else if (typeof format === 'string' && /D/.test(format.substring(0, format.indexOf('MMMM')))) { // if there is a day number before 'MMMM'
return this._monthsGenitiveEl[momentToFormat.month()];
} else {
return this._monthsNominativeEl[momentToFormat.month()];
Expand Down
113 changes: 113 additions & 0 deletions src/locale/gu-IN.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//! moment.js locale configuration
//! locale : gujarati (gu-IN)
//! author : Kaushik Thanki : https://github.com/Kaushik1987
import moment from '../moment';

var symbolMap = {
'1': '૧',
'2': '૨',
'3': '૩',
'4': '૪',
'5': '૫',
'6': '૬',
'7': '૭',
'8': '૮',
'9': '૯',
'0': '૦'
},
numberMap = {
'૧': '1',
'૨': '2',
'૩': '3',
'૪': '4',
'૫': '5',
'૬': '6',
'૭': '7',
'૮': '8',
'૯': '9',
'૦': '0'
};

export default moment.defineLocale('gu-IN', {
months: 'જાન્યુઆરી_ફેબ્રુઆરી_માર્ચ_એપ્રિલ_મે_જૂન_જુલાઈ_ઑગસ્ટ_સપ્ટેમ્બર_ઑક્ટ્બર_નવેમ્બર_ડિસેમ્બર'.split('_'),
monthsShort: 'જાન્યુ._ફેબ્રુ._માર્ચ_એપ્રિ._મે_જૂન_જુલા._ઑગ._સપ્ટે._ઑક્ટ્._નવે._ડિસે.'.split('_'),
monthsParseExact: true,
weekdays: 'રવિવાર_સોમવાર_મંગળવાર_બુધ્વાર_ગુરુવાર_શુક્રવાર_શનિવાર'.split('_'),
weekdaysShort: 'રવિ_સોમ_મંગળ_બુધ્_ગુરુ_શુક્ર_શનિ'.split('_'),
weekdaysMin: 'ર_સો_મં_બુ_ગુ_શુ_શ'.split('_'),
longDateFormat: {
LT: 'A h:mm વાગ્યે',
LTS: 'A h:mm:ss વાગ્યે',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY, A h:mm વાગ્યે',
LLLL: 'dddd, D MMMM YYYY, A h:mm વાગ્યે'
},
calendar: {
sameDay: '[આજ] LT',
nextDay: '[કાલે] LT',
nextWeek: 'dddd, LT',
lastDay: '[ગઇકાલે] LT',
lastWeek: '[પાછલા] dddd, LT',
sameElse: 'L'
},
relativeTime: {
future: '%s મા',
past: '%s પેહલા',
s: 'અમુક પળો',
m: 'એક મિનિટ',
mm: '%d મિનિટ',
h: 'એક કલાક',
hh: '%d કલાક',
d: 'એક દિવસ',
dd: '%d દિવસ',
M: 'એક મહિનો',
MM: '%d મહિનો',
y: 'એક વર્ષ',
yy: '%d વર્ષ'
},
preparse: function (string) {
return string.replace(/[૧૨૩૪૫૬૭૮૯૦]/g, function (match) {
return numberMap[match];
});
},
postformat: function (string) {
return string.replace(/\d/g, function (match) {
return symbolMap[match];
});
},
// Gujarati notation for meridiems are quite fuzzy in practice. While there exists
// a rigid notion of a 'Pahar' it is not used as rigidly in modern Gujarati.
meridiemParse: /રાત|બપોર|સવાર|સાંજ/,
meridiemHour: function (hour, meridiem) {
if (hour === 12) {
hour = 0;
}
if (meridiem === 'રાત') {
return hour < 4 ? hour : hour + 12;
} else if (meridiem === 'સવાર') {
return hour;
} else if (meridiem === 'બપોર') {
return hour >= 10 ? hour : hour + 12;
} else if (meridiem === 'સાંજ') {
return hour + 12;
}
},
meridiem: function (hour, minute, isLower) {
if (hour < 4) {
return 'રાત';
} else if (hour < 10) {
return 'સવાર';
} else if (hour < 17) {
return 'બપોર';
} else if (hour < 20) {
return 'સાંજ';
} else {
return 'રાત';
}
},
week: {
dow: 0, // Sunday is the first day of the week.
doy: 6 // The week that contains Jan 1st is the first week of the year.
}
});
2 changes: 1 addition & 1 deletion src/locale/nl-be.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default moment.defineLocale('nl-be', {

weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
weekdaysMin : 'Zo_Ma_Di_Wo_Do_Vr_Za'.split('_'),
weekdaysMin : 'zo_ma_di_wo_do_vr_za'.split('_'),
weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default moment.defineLocale('nl', {

weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
weekdaysMin : 'Zo_Ma_Di_Wo_Do_Vr_Za'.split('_'),
weekdaysMin : 'zo_ma_di_wo_do_vr_za'.split('_'),
weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
Expand Down
Loading

0 comments on commit 1d393b7

Please sign in to comment.