From d86decf031c56a258dba5d39769c36f00eeefbbd Mon Sep 17 00:00:00 2001 From: paladox Date: Wed, 18 Jun 2014 00:27:39 +0000 Subject: [PATCH] Update Moment.js from 2.6.0 to 2.7.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Project site * http://momentjs.com/ and https://github.com/moment/moment/ File source * https://github.com/moment/moment/blob/2.7.0/moment.js README * https://github.com/moment/moment/blob/2.7.0/readme.md Changelog https://gist.github.com/ichernev/b0a3d456d5a84c9901d7 difference between 2.6.0 and 2.7.0 new languages • #1678 Bengali (bn) • #1628 Azerbaijani (az) • #1633 Arabic, Saudi Arabia (ar-sa) • #1648 Austrian German (de-at) features • #1663 configurable relative time thresholds • #1554 support anchor time in moment.calendar • #1693 support moment.ISO_8601 as parsing format • #1637 add moment.min and moment.max and deprecate min/max instance methods • #1704 support string value in add/subtract • #1647 add spm support (package manager) bugfixes • #1651 fixes #1627 fix timezone parsing in some edge cases • #1641 fixes #1626 fix creation from week/weekday/weekyear for weeks starting monday • #1616 fix language code of cyrillic Serbian (sr-cyrl) and latin Tamazight (tzm-latn) language bugfixes • #1699 fixes #1326 use lowercase months in Italian • #1650 partly fixes #1640 implement meridiem parsing for Russian • #1673 fix lithuanian weekday names for weeks not starting Monday • #1433 Better "time ago" expression for European Portuguese • #1671 Improve welsh past expressions • #1449 Use dot after the day number in Danish • #1559 Update arabic numbers, meridiem and short weekdays • #1622 Fix previous Saturday in Greek tests • #1687 fixed flaky test in Russian timezone Change-Id: If8e065bf9e0962059697e6f08100e7bc966cd32f --- RELEASE-NOTES-1.24 | 1 + resources/Resources.php | 12 +- resources/lib/moment/lang/ar-sa.js | 96 +++++++ resources/lib/moment/lang/ar.js | 43 ++- resources/lib/moment/lang/az.js | 102 ++++++++ resources/lib/moment/lang/bn.js | 106 ++++++++ resources/lib/moment/lang/cy.js | 2 +- resources/lib/moment/lang/da.js | 6 +- resources/lib/moment/lang/de-at.js | 72 +++++ resources/lib/moment/lang/el.js | 13 +- resources/lib/moment/lang/it.js | 4 +- resources/lib/moment/lang/lt.js | 4 +- resources/lib/moment/lang/pt.js | 2 +- resources/lib/moment/lang/ru.js | 5 +- .../lib/moment/lang/{sr-cyr.js => sr-cyrl.js} | 4 +- .../moment/lang/{tzm-la.js => tzm-latn.js} | 4 +- resources/lib/moment/moment.js | 247 +++++++++++++----- 17 files changed, 640 insertions(+), 83 deletions(-) create mode 100644 resources/lib/moment/lang/ar-sa.js create mode 100644 resources/lib/moment/lang/az.js create mode 100644 resources/lib/moment/lang/bn.js create mode 100644 resources/lib/moment/lang/de-at.js rename resources/lib/moment/lang/{sr-cyr.js => sr-cyrl.js} (98%) rename resources/lib/moment/lang/{tzm-la.js => tzm-latn.js} (95%) diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index a923701158..899d2118c4 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -100,6 +100,7 @@ production. Special:PageLanguage. All pages are set to wiki language by default. The feature needs to be enabled with $wgPageLanguageUseDB=true and permission needs to be set for 'pagelang'. +* Upgrade Moment.js to v2.7.0. === Bug fixes in 1.24 === * (bug 49116) Footer copyright notice is now always displayed in user language diff --git a/resources/Resources.php b/resources/Resources.php index 5fec3236b1..4f854fb3e0 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -693,9 +693,12 @@ return array( 'moment' => array( 'scripts' => 'resources/lib/moment/moment.js', 'languageScripts' => array( - 'ar-ma' => 'resources/lib/moment/lang/ar-ma.js', 'ar' => 'resources/lib/moment/lang/ar.js', + 'ar-ma' => 'resources/lib/moment/lang/ar-ma.js', + 'ar-sa' => 'resources/lib/moment/lang/ar-sa.js', + 'az' => 'resources/lib/moment/lang/az.js', 'bg' => 'resources/lib/moment/lang/bg.js', + 'bn' => 'resources/lib/moment/lang/bn.js', 'br' => 'resources/lib/moment/lang/br.js', 'bs' => 'resources/lib/moment/lang/bs.js', 'ca' => 'resources/lib/moment/lang/ca.js', @@ -704,6 +707,7 @@ return array( 'cy' => 'resources/lib/moment/lang/cy.js', 'da' => 'resources/lib/moment/lang/da.js', 'de' => 'resources/lib/moment/lang/de.js', + 'de-at' => 'resources/lib/moment/lang/de-at.js', 'el' => 'resources/lib/moment/lang/el.js', 'en-au' => 'resources/lib/moment/lang/en-au.js', 'en-ca' => 'resources/lib/moment/lang/en-ca.js', @@ -747,15 +751,15 @@ return array( 'sk' => 'resources/lib/moment/lang/sk.js', 'sl' => 'resources/lib/moment/lang/sl.js', 'sq' => 'resources/lib/moment/lang/sq.js', - 'sr-el' => 'resources/lib/moment/lang/sr.js', - 'sr-ec' => 'resources/lib/moment/lang/sr-cyr.js', + 'sr' => 'resources/lib/moment/lang/sr.js', + 'sr-ec' => 'resources/lib/moment/lang/sr-cyrl.js', 'sv' => 'resources/lib/moment/lang/sv.js', 'ta' => 'resources/lib/moment/lang/ta.js', 'th' => 'resources/lib/moment/lang/th.js', 'tl-ph' => 'resources/lib/moment/lang/tl-ph.js', 'tr' => 'resources/lib/moment/lang/tr.js', - 'tzm-la' => 'resources/lib/moment/lang/tzm-la.js', 'tzm' => 'resources/lib/moment/lang/tzm.js', + 'tzm-latn' => 'resources/lib/moment/lang/tzm-latn.js', 'uk' => 'resources/lib/moment/lang/uk.js', 'uz' => 'resources/lib/moment/lang/uz.js', 'vi' => 'resources/lib/moment/lang/vi.js', diff --git a/resources/lib/moment/lang/ar-sa.js b/resources/lib/moment/lang/ar-sa.js new file mode 100644 index 0000000000..162d38612d --- /dev/null +++ b/resources/lib/moment/lang/ar-sa.js @@ -0,0 +1,96 @@ +// moment.js language configuration +// language : Arabic Saudi Arabia (ar-sa) +// author : Suhail Alkowaileet : https://github.com/xsoh + +(function (factory) { + if (typeof define === 'function' && define.amd) { + define(['moment'], factory); // AMD + } else if (typeof exports === 'object') { + module.exports = factory(require('../moment')); // Node + } else { + factory(window.moment); // Browser global + } +}(function (moment) { + var symbolMap = { + '1': '١', + '2': '٢', + '3': '٣', + '4': '٤', + '5': '٥', + '6': '٦', + '7': '٧', + '8': '٨', + '9': '٩', + '0': '٠' + }, numberMap = { + '١': '1', + '٢': '2', + '٣': '3', + '٤': '4', + '٥': '5', + '٦': '6', + '٧': '7', + '٨': '8', + '٩': '9', + '٠': '0' + }; + + return moment.lang('ar-sa', { + months : "يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"), + monthsShort : "يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"), + weekdays : "الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"), + weekdaysShort : "أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"), + weekdaysMin : "ح_ن_ث_ر_خ_ج_س".split("_"), + longDateFormat : { + LT : "HH:mm", + L : "DD/MM/YYYY", + LL : "D MMMM YYYY", + LLL : "D MMMM YYYY LT", + LLLL : "dddd D MMMM YYYY LT" + }, + meridiem : function (hour, minute, isLower) { + if (hour < 12) { + return "ص"; + } else { + return "م"; + } + }, + 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]; + }).replace(/،/g, ','); + }, + postformat: function (string) { + return string.replace(/\d/g, function (match) { + return symbolMap[match]; + }).replace(/,/g, '،'); + }, + week : { + dow : 6, // Saturday is the first day of the week. + doy : 12 // The week that contains Jan 1st is the first week of the year. + } + }); +})); diff --git a/resources/lib/moment/lang/ar.js b/resources/lib/moment/lang/ar.js index 6e27d29a93..dd01a42cfd 100644 --- a/resources/lib/moment/lang/ar.js +++ b/resources/lib/moment/lang/ar.js @@ -12,11 +12,35 @@ factory(window.moment); // Browser global } }(function (moment) { + var symbolMap = { + '1': '١', + '2': '٢', + '3': '٣', + '4': '٤', + '5': '٥', + '6': '٦', + '7': '٧', + '8': '٨', + '9': '٩', + '0': '٠' + }, numberMap = { + '١': '1', + '٢': '2', + '٣': '3', + '٤': '4', + '٥': '5', + '٦': '6', + '٧': '7', + '٨': '8', + '٩': '9', + '٠': '0' + }; + return moment.lang('ar', { months : "يناير/ كانون الثاني_فبراير/ شباط_مارس/ آذار_أبريل/ نيسان_مايو/ أيار_يونيو/ حزيران_يوليو/ تموز_أغسطس/ آب_سبتمبر/ أيلول_أكتوبر/ تشرين الأول_نوفمبر/ تشرين الثاني_ديسمبر/ كانون الأول".split("_"), monthsShort : "يناير/ كانون الثاني_فبراير/ شباط_مارس/ آذار_أبريل/ نيسان_مايو/ أيار_يونيو/ حزيران_يوليو/ تموز_أغسطس/ آب_سبتمبر/ أيلول_أكتوبر/ تشرين الأول_نوفمبر/ تشرين الثاني_ديسمبر/ كانون الأول".split("_"), weekdays : "الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"), - weekdaysShort : "الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"), + weekdaysShort : "أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"), weekdaysMin : "ح_ن_ث_ر_خ_ج_س".split("_"), longDateFormat : { LT : "HH:mm", @@ -25,6 +49,13 @@ LLL : "D MMMM YYYY LT", LLLL : "dddd D MMMM YYYY LT" }, + meridiem : function (hour, minute, isLower) { + if (hour < 12) { + return "ص"; + } else { + return "م"; + } + }, calendar : { sameDay: "[اليوم على الساعة] LT", nextDay: '[غدا على الساعة] LT', @@ -48,6 +79,16 @@ y : "سنة", yy : "%d سنوات" }, + preparse: function (string) { + return string.replace(/[۰-۹]/g, function (match) { + return numberMap[match]; + }).replace(/،/g, ','); + }, + postformat: function (string) { + return string.replace(/\d/g, function (match) { + return symbolMap[match]; + }).replace(/,/g, '،'); + }, week : { dow : 6, // Saturday is the first day of the week. doy : 12 // The week that contains Jan 1st is the first week of the year. diff --git a/resources/lib/moment/lang/az.js b/resources/lib/moment/lang/az.js new file mode 100644 index 0000000000..bee1f9a334 --- /dev/null +++ b/resources/lib/moment/lang/az.js @@ -0,0 +1,102 @@ +// moment.js language configuration +// language : azerbaijani (az) +// author : topchiyev : https://github.com/topchiyev + +(function (factory) { + if (typeof define === 'function' && define.amd) { + define(['moment'], factory); // AMD + } else if (typeof exports === 'object') { + module.exports = factory(require('../moment')); // Node + } else { + factory(window.moment); // Browser global + } +}(function (moment) { + + var suffixes = { + 1: "-inci", + 5: "-inci", + 8: "-inci", + 70: "-inci", + 80: "-inci", + + 2: "-nci", + 7: "-nci", + 20: "-nci", + 50: "-nci", + + 3: "-üncü", + 4: "-üncü", + 100: "-üncü", + + 6: "-ncı", + + 9: "-uncu", + 10: "-uncu", + 30: "-uncu", + + 60: "-ıncı", + 90: "-ıncı" + }; + return moment.lang('az', { + months : "yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr".split("_"), + monthsShort : "yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek".split("_"), + weekdays : "Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə".split("_"), + weekdaysShort : "Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən".split("_"), + weekdaysMin : "Bz_BE_ÇA_Çə_CA_Cü_Şə".split("_"), + longDateFormat : { + LT : "HH:mm", + L : "DD.MM.YYYY", + LL : "D MMMM YYYY", + LLL : "D MMMM YYYY LT", + LLLL : "dddd, D MMMM YYYY LT" + }, + calendar : { + sameDay : '[bugün saat] LT', + nextDay : '[sabah saat] LT', + nextWeek : '[gələn həftə] dddd [saat] LT', + lastDay : '[dünən] LT', + lastWeek : '[keçən həftə] dddd [saat] LT', + sameElse : 'L' + }, + relativeTime : { + future : "%s sonra", + past : "%s əvvəl", + s : "birneçə saniyyə", + m : "bir dəqiqə", + mm : "%d dəqiqə", + h : "bir saat", + hh : "%d saat", + d : "bir gün", + dd : "%d gün", + M : "bir ay", + MM : "%d ay", + y : "bir il", + yy : "%d il" + }, + meridiem : function (hour, minute, isLower) { + if (hour < 4) { + return "gecə"; + } else if (hour < 12) { + return "səhər"; + } else if (hour < 17) { + return "gündüz"; + } else { + return "axşam"; + } + }, + ordinal : function (number) { + if (number === 0) { // special case for zero + return number + "-ıncı"; + } + var a = number % 10, + b = number % 100 - a, + c = number >= 100 ? 100 : null; + + return number + (suffixes[a] || suffixes[b] || suffixes[c]); + }, + week : { + dow : 1, // Monday is the first day of the week. + doy : 7 // The week that contains Jan 1st is the first week of the year. + } + }); +})); diff --git a/resources/lib/moment/lang/bn.js b/resources/lib/moment/lang/bn.js new file mode 100644 index 0000000000..fb23bd00f2 --- /dev/null +++ b/resources/lib/moment/lang/bn.js @@ -0,0 +1,106 @@ +// moment.js language configuration +// language : Bengali (bn) +// author : Kaushik Gandhi : https://github.com/kaushikgandhi + +(function (factory) { + if (typeof define === 'function' && define.amd) { + define(['moment'], factory); // AMD + } else if (typeof exports === 'object') { + module.exports = factory(require('../moment')); // Node + } else { + factory(window.moment); // Browser global + } +}(function (moment) { + var symbolMap = { + '1': '১', + '2': '২', + '3': '৩', + '4': '৪', + '5': '৫', + '6': '৬', + '7': '৭', + '8': '৮', + '9': '৯', + '0': '০' + }, + numberMap = { + '১': '1', + '২': '2', + '৩': '3', + '৪': '4', + '৫': '5', + '৬': '6', + '৭': '7', + '৮': '8', + '৯': '9', + '০': '0' + }; + + return moment.lang('bn', { + months : 'জানুয়ারী_ফেবুয়ারী_মার্চ_এপ্রিল_মে_জুন_জুলাই_অগাস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split("_"), + monthsShort : 'জানু_ফেব_মার্চ_এপর_মে_জুন_জুল_অগ_সেপ্ট_অক্টো_নভ_ডিসেম্'.split("_"), + weekdays : 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পত্তিবার_শুক্রুবার_শনিবার'.split("_"), + weekdaysShort : 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পত্তি_শুক্রু_শনি'.split("_"), + weekdaysMin : 'রব_সম_মঙ্গ_বু_ব্রিহ_শু_শনি'.split("_"), + longDateFormat : { + LT : "A h:mm সময়", + L : "DD/MM/YYYY", + LL : "D MMMM YYYY", + LLL : "D MMMM YYYY, LT", + LLLL : "dddd, D MMMM YYYY, LT" + }, + 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]; + }); + }, + //Bengali is a vast language its spoken + //in different forms in various parts of the world. + //I have just generalized with most common one used + 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. + } + }); +})); diff --git a/resources/lib/moment/lang/cy.js b/resources/lib/moment/lang/cy.js index b47d7c2751..5cd8476b9b 100644 --- a/resources/lib/moment/lang/cy.js +++ b/resources/lib/moment/lang/cy.js @@ -35,7 +35,7 @@ }, relativeTime: { future: "mewn %s", - past: "%s yn àl", + past: "%s yn ôl", s: "ychydig eiliadau", m: "munud", mm: "%d munud", diff --git a/resources/lib/moment/lang/da.js b/resources/lib/moment/lang/da.js index 2fa8244c01..e06f8c3621 100644 --- a/resources/lib/moment/lang/da.js +++ b/resources/lib/moment/lang/da.js @@ -20,9 +20,9 @@ longDateFormat : { LT : "HH:mm", L : "DD/MM/YYYY", - LL : "D MMMM YYYY", - LLL : "D MMMM YYYY LT", - LLLL : "dddd D. MMMM, YYYY LT" + LL : "D. MMMM YYYY", + LLL : "D. MMMM YYYY LT", + LLLL : "dddd [d.] D. MMMM YYYY LT" }, calendar : { sameDay : '[I dag kl.] LT', diff --git a/resources/lib/moment/lang/de-at.js b/resources/lib/moment/lang/de-at.js new file mode 100644 index 0000000000..565c12b722 --- /dev/null +++ b/resources/lib/moment/lang/de-at.js @@ -0,0 +1,72 @@ +// moment.js language configuration +// language : austrian german (de-at) +// author : lluchs : https://github.com/lluchs +// author: Menelion Elensúle: https://github.com/Oire +// author : Martin Groller : https://github.com/MadMG + +(function (factory) { + if (typeof define === 'function' && define.amd) { + define(['moment'], factory); // AMD + } else if (typeof exports === 'object') { + module.exports = factory(require('../moment')); // Node + } else { + factory(window.moment); // Browser global + } +}(function (moment) { + function processRelativeTime(number, withoutSuffix, key, isFuture) { + var format = { + 'm': ['eine Minute', 'einer Minute'], + 'h': ['eine Stunde', 'einer Stunde'], + 'd': ['ein Tag', 'einem Tag'], + 'dd': [number + ' Tage', number + ' Tagen'], + 'M': ['ein Monat', 'einem Monat'], + 'MM': [number + ' Monate', number + ' Monaten'], + 'y': ['ein Jahr', 'einem Jahr'], + 'yy': [number + ' Jahre', number + ' Jahren'] + }; + return withoutSuffix ? format[key][0] : format[key][1]; + } + + return moment.lang('de-at', { + months : "Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"), + monthsShort : "Jän._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.".split("_"), + weekdays : "Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"), + weekdaysShort : "So._Mo._Di._Mi._Do._Fr._Sa.".split("_"), + weekdaysMin : "So_Mo_Di_Mi_Do_Fr_Sa".split("_"), + longDateFormat : { + LT: "HH:mm [Uhr]", + L : "DD.MM.YYYY", + LL : "D. MMMM YYYY", + LLL : "D. MMMM YYYY LT", + LLLL : "dddd, D. MMMM YYYY LT" + }, + calendar : { + sameDay: "[Heute um] LT", + sameElse: "L", + nextDay: '[Morgen um] LT', + nextWeek: 'dddd [um] LT', + lastDay: '[Gestern um] LT', + lastWeek: '[letzten] dddd [um] LT' + }, + relativeTime : { + future : "in %s", + past : "vor %s", + s : "ein paar Sekunden", + m : processRelativeTime, + mm : "%d Minuten", + h : processRelativeTime, + hh : "%d Stunden", + d : processRelativeTime, + dd : processRelativeTime, + M : processRelativeTime, + MM : processRelativeTime, + y : processRelativeTime, + yy : processRelativeTime + }, + ordinal : '%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. + } + }); +})); diff --git a/resources/lib/moment/lang/el.js b/resources/lib/moment/lang/el.js index 9dfea239d8..e2a38cdb54 100644 --- a/resources/lib/moment/lang/el.js +++ b/resources/lib/moment/lang/el.js @@ -44,13 +44,24 @@ nextDay : '[Αύριο {}] LT', nextWeek : 'dddd [{}] LT', lastDay : '[Χθες {}] LT', - lastWeek : '[την προηγούμενη] dddd [{}] LT', + lastWeek : function() { + switch (this.day()) { + case 6: + return '[το προηγούμενο] dddd [{}] LT'; + default: + return '[την προηγούμενη] dddd [{}] LT'; + } + }, sameElse : 'L' }, calendar : function (key, mom) { var output = this._calendarEl[key], hours = mom && mom.hours(); + if (typeof output === 'function') { + output = output.apply(mom); + } + return output.replace("{}", (hours % 12 === 1 ? "στη" : "στις")); }, relativeTime : { diff --git a/resources/lib/moment/lang/it.js b/resources/lib/moment/lang/it.js index 84b7698be5..9c27f665a5 100644 --- a/resources/lib/moment/lang/it.js +++ b/resources/lib/moment/lang/it.js @@ -13,8 +13,8 @@ } }(function (moment) { return moment.lang('it', { - months : "Gennaio_Febbraio_Marzo_Aprile_Maggio_Giugno_Luglio_Agosto_Settembre_Ottobre_Novembre_Dicembre".split("_"), - monthsShort : "Gen_Feb_Mar_Apr_Mag_Giu_Lug_Ago_Set_Ott_Nov_Dic".split("_"), + months : "gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"), + monthsShort : "gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"), weekdays : "Domenica_Lunedì_Martedì_Mercoledì_Giovedì_Venerdì_Sabato".split("_"), weekdaysShort : "Dom_Lun_Mar_Mer_Gio_Ven_Sab".split("_"), weekdaysMin : "D_L_Ma_Me_G_V_S".split("_"), diff --git a/resources/lib/moment/lang/lt.js b/resources/lib/moment/lang/lt.js index 3377375cd4..3c11b89bd3 100644 --- a/resources/lib/moment/lang/lt.js +++ b/resources/lib/moment/lang/lt.js @@ -23,7 +23,7 @@ "y" : "metai_metų_metus", "yy": "metai_metų_metus" }, - weekDays = "pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis_sekmadienis".split("_"); + weekDays = "sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis".split("_"); function translateSeconds(number, withoutSuffix, key, isFuture) { if (withoutSuffix) { @@ -62,7 +62,7 @@ function relativeWeekDay(moment, format) { var nominative = format.indexOf('dddd HH:mm') === -1, - weekDay = weekDays[moment.weekday()]; + weekDay = weekDays[moment.day()]; return nominative ? weekDay : weekDay.substring(0, weekDay.length - 2) + "į"; } diff --git a/resources/lib/moment/lang/pt.js b/resources/lib/moment/lang/pt.js index 77e1cad315..3042844d00 100644 --- a/resources/lib/moment/lang/pt.js +++ b/resources/lib/moment/lang/pt.js @@ -38,7 +38,7 @@ }, relativeTime : { future : "em %s", - past : "%s atrás", + past : "há %s", s : "segundos", m : "um minuto", mm : "%d minutos", diff --git a/resources/lib/moment/lang/ru.js b/resources/lib/moment/lang/ru.js index ac5400da8a..dc013a7fc4 100644 --- a/resources/lib/moment/lang/ru.js +++ b/resources/lib/moment/lang/ru.js @@ -125,7 +125,10 @@ yy : relativeTimeWithPlural }, - // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason + meridiemParse: /ночи|утра|дня|вечера/i, + isPM : function (input) { + return /^(дня|вечера)$/.test(input); + }, meridiem : function (hour, minute, isLower) { if (hour < 4) { diff --git a/resources/lib/moment/lang/sr-cyr.js b/resources/lib/moment/lang/sr-cyrl.js similarity index 98% rename from resources/lib/moment/lang/sr-cyr.js rename to resources/lib/moment/lang/sr-cyrl.js index 8d186890b8..ae1754b34d 100644 --- a/resources/lib/moment/lang/sr-cyr.js +++ b/resources/lib/moment/lang/sr-cyrl.js @@ -1,5 +1,5 @@ // moment.js language configuration -// language : Serbian-cyrillic (sr-cyr) +// language : Serbian-cyrillic (sr-cyrl) // author : Milan Janačković : https://github.com/milan-j (function (factory) { @@ -35,7 +35,7 @@ } }; - return moment.lang('sr-cyr', { + return moment.lang('sr-cyrl', { months: ['јануар', 'фебруар', 'март', 'април', 'мај', 'јун', 'јул', 'август', 'септембар', 'октобар', 'новембар', 'децембар'], monthsShort: ['јан.', 'феб.', 'мар.', 'апр.', 'мај', 'јун', 'јул', 'авг.', 'сеп.', 'окт.', 'нов.', 'дец.'], weekdays: ['недеља', 'понедељак', 'уторак', 'среда', 'четвртак', 'петак', 'субота'], diff --git a/resources/lib/moment/lang/tzm-la.js b/resources/lib/moment/lang/tzm-latn.js similarity index 95% rename from resources/lib/moment/lang/tzm-la.js rename to resources/lib/moment/lang/tzm-latn.js index be1d878ddf..f7e9089773 100644 --- a/resources/lib/moment/lang/tzm-la.js +++ b/resources/lib/moment/lang/tzm-latn.js @@ -1,5 +1,5 @@ // moment.js language configuration -// language : Morocco Central Atlas Tamaziɣt in Latin (tzm-la) +// language : Morocco Central Atlas Tamaziɣt in Latin (tzm-latn) // author : Abdel Said : https://github.com/abdelsaid (function (factory) { @@ -11,7 +11,7 @@ factory(window.moment); // Browser global } }(function (moment) { - return moment.lang('tzm-la', { + return moment.lang('tzm-latn', { months : "innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"), monthsShort : "innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"), weekdays : "asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"), diff --git a/resources/lib/moment/moment.js b/resources/lib/moment/moment.js index 257ee7ec1a..83282c6fdb 100644 --- a/resources/lib/moment/moment.js +++ b/resources/lib/moment/moment.js @@ -1,5 +1,5 @@ //! moment.js -//! version : 2.6.0 +//! version : 2.7.0 //! authors : Tim Wood, Iskren Chernev, Moment.js contributors //! license : MIT //! momentjs.com @@ -11,7 +11,7 @@ ************************************/ var moment, - VERSION = "2.6.0", + VERSION = "2.7.0", // the global-scope this is NOT the global object in Node.js globalScope = typeof global !== 'undefined' ? global : this, oldGlobalMoment, @@ -36,6 +36,7 @@ _f : null, _l : null, _strict : null, + _tzm : null, _isUTC : null, _offset : null, // optional. Combine with _isUTC _pf : null, @@ -144,6 +145,16 @@ // format function strings formatFunctions = {}, + // default relative time thresholds + relativeTimeThresholds = { + s: 45, //seconds to minutes + m: 45, //minutes to hours + h: 22, //hours to days + dd: 25, //days to month (month == 1) + dm: 45, //days to months (months > 1) + dy: 345 //days to year + }, + // tokens to ordinalize and pad ordinalizeTokens = 'DDD w W M D d'.split(' '), paddedTokens = 'M D H h m s w W'.split(' '), @@ -283,6 +294,16 @@ lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin']; + // Pick the first defined of two or three arguments. dfl comes from + // default. + function dfl(a, b, c) { + switch (arguments.length) { + case 2: return a != null ? a : b; + case 3: return a != null ? a : b != null ? b : c; + default: throw new Error("Implement me"); + } + } + function defaultParsingFlags() { // We need to deep clone this object, and es5 standard is not very // helpful. @@ -1151,39 +1172,94 @@ config._useUTC = true; config._tzm = timezoneMinutesFromString(input); break; + // WEEKDAY - human + case 'dd': + case 'ddd': + case 'dddd': + a = getLangDefinition(config._l).weekdaysParse(input); + // if we didn't get a weekday name, mark the date as invalid + if (a != null) { + config._w = config._w || {}; + config._w['d'] = a; + } else { + config._pf.invalidWeekday = input; + } + break; + // WEEK, WEEK DAY - numeric case 'w': case 'ww': case 'W': case 'WW': case 'd': - case 'dd': - case 'ddd': - case 'dddd': case 'e': case 'E': token = token.substr(0, 1); /* falls through */ - case 'gg': case 'gggg': - case 'GG': case 'GGGG': case 'GGGGG': token = token.substr(0, 2); if (input) { config._w = config._w || {}; - config._w[token] = input; + config._w[token] = toInt(input); } break; + case 'gg': + case 'GG': + config._w = config._w || {}; + config._w[token] = moment.parseTwoDigitYear(input); } } + function dayOfYearFromWeekInfo(config) { + var w, weekYear, week, weekday, dow, doy, temp, lang; + + w = config._w; + if (w.GG != null || w.W != null || w.E != null) { + dow = 1; + doy = 4; + + // TODO: We need to take the current isoWeekYear, but that depends on + // how we interpret now (local, utc, fixed offset). So create + // a now version of current config (take local/utc/offset flags, and + // create now). + weekYear = dfl(w.GG, config._a[YEAR], weekOfYear(moment(), 1, 4).year); + week = dfl(w.W, 1); + weekday = dfl(w.E, 1); + } else { + lang = getLangDefinition(config._l); + dow = lang._week.dow; + doy = lang._week.doy; + + weekYear = dfl(w.gg, config._a[YEAR], weekOfYear(moment(), dow, doy).year); + week = dfl(w.w, 1); + + if (w.d != null) { + // weekday -- low day numbers are considered next week + weekday = w.d; + if (weekday < dow) { + ++week; + } + } else if (w.e != null) { + // local weekday -- counting starts from begining of week + weekday = w.e + dow; + } else { + // default to begining of week + weekday = dow; + } + } + temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow); + + config._a[YEAR] = temp.year; + config._dayOfYear = temp.dayOfYear; + } + // convert an array to a date. // the array should mirror the parameters below // note: all values past the year are optional and will default to the lowest possible value. // [year, month, day , hour, minute, second, millisecond] function dateFromConfig(config) { - var i, date, input = [], currentDate, - yearToUse, fixYear, w, temp, lang, weekday, week; + var i, date, input = [], currentDate, yearToUse; if (config._d) { return; @@ -1193,39 +1269,12 @@ //compute day of the year from weeks and weekdays if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { - fixYear = function (val) { - var intVal = parseInt(val, 10); - return val ? - (val.length < 3 ? (intVal > 68 ? 1900 + intVal : 2000 + intVal) : intVal) : - (config._a[YEAR] == null ? moment().weekYear() : config._a[YEAR]); - }; - - w = config._w; - if (w.GG != null || w.W != null || w.E != null) { - temp = dayOfYearFromWeeks(fixYear(w.GG), w.W || 1, w.E, 4, 1); - } - else { - lang = getLangDefinition(config._l); - weekday = w.d != null ? parseWeekday(w.d, lang) : - (w.e != null ? parseInt(w.e, 10) + lang._week.dow : 0); - - week = parseInt(w.w, 10) || 1; - - //if we're parsing 'd', then the low day numbers may be next week - if (w.d != null && weekday < lang._week.dow) { - week++; - } - - temp = dayOfYearFromWeeks(fixYear(w.gg), week, weekday, lang._week.doy, lang._week.dow); - } - - config._a[YEAR] = temp.year; - config._dayOfYear = temp.dayOfYear; + dayOfYearFromWeekInfo(config); } //if the day of the year is set, figure out what it is if (config._dayOfYear) { - yearToUse = config._a[YEAR] == null ? currentDate[YEAR] : config._a[YEAR]; + yearToUse = dfl(config._a[YEAR], currentDate[YEAR]); if (config._dayOfYear > daysInYear(yearToUse)) { config._pf._overflowDayOfYear = true; @@ -1250,11 +1299,12 @@ config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; } - // add the offsets to the time to be parsed so that we can have a clean array for checking isValid - input[HOUR] += toInt((config._tzm || 0) / 60); - input[MINUTE] += toInt((config._tzm || 0) % 60); - config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input); + // Apply timezone offset from input. The actual zone can be changed + // with parseZone. + if (config._tzm != null) { + config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm); + } } function dateFromObject(config) { @@ -1294,6 +1344,11 @@ // date from string and format string function makeDateFromStringAndFormat(config) { + if (config._f === moment.ISO_8601) { + parseISO(config); + return; + } + config._a = []; config._pf.empty = true; @@ -1406,7 +1461,7 @@ } // date from iso format - function makeDateFromString(config) { + function parseISO(config) { var i, l, string = config._i, match = isoRegex.exec(string); @@ -1430,8 +1485,16 @@ config._f += "Z"; } makeDateFromStringAndFormat(config); + } else { + config._isValid = false; } - else { + } + + // date from iso format or fallback + function makeDateFromString(config) { + parseISO(config); + if (config._isValid === false) { + delete config._isValid; moment.createFromInputFallback(config); } } @@ -1512,15 +1575,15 @@ hours = round(minutes / 60), days = round(hours / 24), years = round(days / 365), - args = seconds < 45 && ['s', seconds] || + args = seconds < relativeTimeThresholds.s && ['s', seconds] || minutes === 1 && ['m'] || - minutes < 45 && ['mm', minutes] || + minutes < relativeTimeThresholds.m && ['mm', minutes] || hours === 1 && ['h'] || - hours < 22 && ['hh', hours] || + hours < relativeTimeThresholds.h && ['hh', hours] || days === 1 && ['d'] || - days <= 25 && ['dd', days] || - days <= 45 && ['M'] || - days < 345 && ['MM', round(days / 30)] || + days <= relativeTimeThresholds.dd && ['dd', days] || + days <= relativeTimeThresholds.dm && ['M'] || + days < relativeTimeThresholds.dy && ['MM', round(days / 30)] || years === 1 && ['y'] || ['yy', years]; args[2] = withoutSuffix; args[3] = milliseconds > 0; @@ -1566,6 +1629,7 @@ function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) { var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear; + d = d === 0 ? 7 : d; weekday = weekday != null ? weekday : firstDayOfWeek; daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0); dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1; @@ -1641,6 +1705,40 @@ config._d = new Date(config._i); }); + // Pick a moment m from moments so that m[fn](other) is true for all + // other. This relies on the function fn to be transitive. + // + // moments should either be an array of moment objects or an array, whose + // first element is an array of moment objects. + function pickBy(fn, moments) { + var res, i; + if (moments.length === 1 && isArray(moments[0])) { + moments = moments[0]; + } + if (!moments.length) { + return moment(); + } + res = moments[0]; + for (i = 1; i < moments.length; ++i) { + if (moments[i][fn](res)) { + res = moments[i]; + } + } + return res; + } + + moment.min = function () { + var args = [].slice.call(arguments, 0); + + return pickBy('isBefore', args); + }; + + moment.max = function () { + var args = [].slice.call(arguments, 0); + + return pickBy('isAfter', args); + }; + // creating with utc moment.utc = function (input, format, lang, strict) { var c; @@ -1737,6 +1835,9 @@ // default format moment.defaultFormat = isoFormat; + // constant that refers to the ISO standard + moment.ISO_8601 = function () {}; + // Plugins that add properties should also add the key here (null value), // so we can properly clone ourselves. moment.momentProperties = momentProperties; @@ -1745,6 +1846,15 @@ // It is intended to keep the offset in sync with the timezone. moment.updateOffset = function () {}; + // This function allows you to set a threshold for relative time strings + moment.relativeTimeThreshold = function(threshold, limit) { + if (relativeTimeThresholds[threshold] === undefined) { + return false; + } + relativeTimeThresholds[threshold] = limit; + return true; + }; + // This function will load languages and then set the global language. If // no arguments are passed in, it will simply return the current global // language key. @@ -1900,7 +2010,9 @@ add : function (input, val) { var dur; // switch args to support add('s', 1) and add(1, 's') - if (typeof input === 'string') { + if (typeof input === 'string' && typeof val === 'string') { + dur = moment.duration(isNaN(+val) ? +input : +val, isNaN(+val) ? val : input); + } else if (typeof input === 'string') { dur = moment.duration(+val, input); } else { dur = moment.duration(input, val); @@ -1912,7 +2024,9 @@ subtract : function (input, val) { var dur; // switch args to support subtract('s', 1) and subtract(1, 's') - if (typeof input === 'string') { + if (typeof input === 'string' && typeof val === 'string') { + dur = moment.duration(isNaN(+val) ? +input : +val, isNaN(+val) ? val : input); + } else if (typeof input === 'string') { dur = moment.duration(+val, input); } else { dur = moment.duration(input, val); @@ -1963,10 +2077,11 @@ return this.from(moment(), withoutSuffix); }, - calendar : function () { + calendar : function (time) { // We want to compare the start of today, vs this. // Getting start-of-today depends on whether we're zone'd or not. - var sod = makeAs(moment(), this).startOf('day'), + var now = time || moment(), + sod = makeAs(now, this).startOf('day'), diff = this.diff(sod, 'days', true), format = diff < -6 ? 'sameElse' : diff < -1 ? 'lastWeek' : @@ -2061,15 +2176,21 @@ return +this.clone().startOf(units) === +makeAs(input, this).startOf(units); }, - min: function (other) { - other = moment.apply(null, arguments); - return other < this ? this : other; - }, + min: deprecate( + "moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548", + function (other) { + other = moment.apply(null, arguments); + return other < this ? this : other; + } + ), - max: function (other) { - other = moment.apply(null, arguments); - return other > this ? this : other; - }, + max: deprecate( + "moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548", + function (other) { + other = moment.apply(null, arguments); + return other > this ? this : other; + } + ), // keepTime = true means only change the timezone, without affecting // the local hour. So 5:31:26 +0300 --[zone(2, true)]--> 5:31:26 +0200 -- 2.20.1