diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..b030576145 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,34 @@ +Submitting Issues +================= + +If you are submitting a bug with moment, please create a [jsfiddle](http://jsfiddle.net/) demonstrating the issue. + +Contributing +============ + +To contribute, fork the library and install these npm packages. + + npm install jshint uglify-js nodeunit + +You can add tests to the files in `/test/moment` or add a new test file if you are adding a new feature. + +To run the tests, do `make test` to run all tests, `make test-moment` to test the core library, and `make test-lang` to test all the languages. + +To check the filesize, you can use `make size`. + +To minify all the files, use `make moment` to minify moment, `make langs` to minify all the lang files, or just `make` to minfy everything. + +If your code passes the unit tests (including the ones you wrote), submit a pull request. + +Submitting pull requests +======================== + +Moment.js now uses [git-flow](https://github.com/nvie/gitflow). If you're not familiar with git-flow, please read up on it, you'll be glad you did. + +When submitting new features, please create a new feature branch using `git flow feature start ` and submit the pull request to the `develop` branch. + +Pull requests for enhancements for features should be submitted to the `develop` branch as well. + +When submitting a bugfix, please check if there is an existing bugfix branch. If the latest stable version is `1.5.0`, the bugfix branch would be `hotfix/1.5.1`. All pull requests for bug fixes should be on a `hotfix` branch, unless the bug fix depends on a new feature. + +The `master` branch should always have the latest stable version. When bugfix or minor releases are needed, the develop/hotfix branch will be merged into master and released. diff --git a/lang/ro.js b/lang/ro.js new file mode 100644 index 0000000000..0856b395d4 --- /dev/null +++ b/lang/ro.js @@ -0,0 +1,55 @@ +// moment.js language configuration +// language : romanian (ro) +// author : Vlad Gurdiga : https://github.com/gurdiga +// author : Valentin Agachi : https://github.com/avaly +(function () { + var lang = { + months : "Ianuarie_Februarie_Martie_Aprilie_Mai_Iunie_Iulie_August_Septembrie_Octombrie_Noiembrie_Decembrie".split("_"), + monthsShort : "Ian_Feb_Mar_Apr_Mai_Iun_Iul_Aug_Sep_Oct_Noi_Dec".split("_"), + weekdays : "Duminică_Luni_Marţi_Miercuri_Joi_Vineri_Sâmbătă".split("_"), + weekdaysShort : "Dum_Lun_Mar_Mie_Joi_Vin_Sâm".split("_"), + weekdaysMin : "Du_Lu_Ma_Mi_Jo_Vi_Sâ".split("_"), + longDateFormat : { + LT : "H:mm", + L : "DD/MM/YYYY", + LL : "D MMMM YYYY", + LLL : "D MMMM YYYY H:mm", + LLLL : "dddd, D MMMM YYYY H:mm" + }, + calendar : { + sameDay: "[azi la] LT", + nextDay: '[mâine la] LT', + nextWeek: 'dddd [la] LT', + lastDay: '[ieri la] LT', + lastWeek: '[fosta] dddd [la] LT', + sameElse: 'L' + }, + relativeTime : { + future : "peste %s", + past : "%s în urmă", + s : "câteva secunde", + m : "un minut", + mm : "%d minute", + h : "o oră", + hh : "%d ore", + d : "o zi", + dd : "%d zile", + M : "o lună", + MM : "%d luni", + y : "un an", + yy : "%d ani" + }, + ordinal : function (number) { + return ''; + } + }; + + // Node + if (typeof module !== 'undefined') { + module.exports = lang; + } + // Browser + if (typeof window !== 'undefined' && this.moment && this.moment.lang) { + this.moment.lang('ro', lang); + } +}()); diff --git a/readme.md b/readme.md index a03792113e..4c3b61074f 100755 --- a/readme.md +++ b/readme.md @@ -22,36 +22,6 @@ There are a few things being deprecated in the 1.6.0 release. 3. The way to customize am/pm strings is being changed. This would only affect you if you created a custom language file. For more information, see [this issue](https://github.com/timrwood/moment/pull/222). -Contributing -============ - -To contribute, fork the library and install these npm packages. - - npm install jshint uglify-js nodeunit - -You can add tests to the files in `/test/moment` or add a new test file if you are adding a new feature. - -To run the tests, do `make test` to run all tests, `make test-moment` to test the core library, and `make test-lang` to test all the languages. - -To check the filesize, you can use `make size`. - -To minify all the files, use `make moment` to minify moment, `make langs` to minify all the lang files, or just `make` to minfy everything. - -If your code passes the unit tests (including the ones you wrote), submit a pull request. - -Submitting pull requests -======================== - -Moment.js now uses [git-flow](https://github.com/nvie/gitflow). If you're not familiar with git-flow, please read up on it, you'll be glad you did. - -When submitting new features, please create a new feature branch using `git flow feature start ` and submit the pull request to the `develop` branch. - -Pull requests for enhancements for features should be submitted to the `develop` branch as well. - -When submitting a bugfix, please check if there is an existing bugfix branch. If the latest stable version is `1.5.0`, the bugfix branch would be `hotfix/1.5.1`. All pull requests for bug fixes should be on a `hotfix` branch, unless the bug fix depends on a new feature. - -The `master` branch should always have the latest stable version. When bugfix or minor releases are needed, the develop/hotfix branch will be merged into master and released. - Changelog ========= @@ -162,11 +132,11 @@ Added _date.lang() support. Added support for passing multiple formats to try to parse a date. _date("07-10-1986", ["MM-DD-YYYY", "YYYY-MM-DD"]); Made parse from string and single format 25% faster. -### 0.5.2 +### 0.5.2 Buxfix for [issue 8](https://github.com/timrwood/underscore.date/pull/8) and [issue 9](https://github.com/timrwood/underscore.date/pull/9). -### 0.5.1 +### 0.5.1 Buxfix for [issue 5](https://github.com/timrwood/underscore.date/pull/5). @@ -177,11 +147,11 @@ Removed `_date.now()`, as it is a duplicate of `_date()` with no parameters. Removed `_date.isLeapYear(yearNuumber)`. Use `_date([yearNumber]).isLeapYear()` instead. Exposed customization options through the `_date.relativeTime`, `_date.weekdays`, `_date.weekdaysShort`, `_date.months`, `_date.monthsShort`, and `_date.ordinal` variables instead of the `_date.customize()` function. -### 0.4.1 +### 0.4.1 Added date input formats for input strings. -### 0.4.0 +### 0.4.0 Added underscore.date to npm. Removed dependancies on underscore. @@ -191,7 +161,7 @@ Added `'z'` and `'zz'` to `_.date().format()`. Cleaned up some redundant code to ### 0.3.1 -Cleaned up the namespace. Moved all date manipulation and display functions to the _.date() object. +Cleaned up the namespace. Moved all date manipulation and display functions to the _.date() object. ### 0.3.0 @@ -225,4 +195,4 @@ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/test/lang/ro.js b/test/lang/ro.js new file mode 100644 index 0000000000..1773584e33 --- /dev/null +++ b/test/lang/ro.js @@ -0,0 +1,248 @@ +var moment = require("../../moment"); + + + /************************************************** + Romanian + *************************************************/ + +exports["lang:ro"] = { + "parse" : function(test) { + test.expect(96); + moment.lang('ro'); + var tests = 'Ianuarie Ian_Februarie Feb_Martie Mar_Aprilie Apr_Mai Mai_Iunie Iun_Iulie Iul_August Aug_Septembrie Sep_Octombrie Oct_Noiembrie Noi_Decembrie Dec'.split("_"); + var i; + function equalTest(input, mmm, i) { + test.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1)); + } + for (i = 0; i < 12; i++) { + tests[i] = tests[i].split(' '); + equalTest(tests[i][0], 'MMM', i); + equalTest(tests[i][1], 'MMM', i); + equalTest(tests[i][0], 'MMMM', i); + equalTest(tests[i][1], 'MMMM', i); + equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i); + equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i); + equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i); + equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i); + } + test.done(); + }, + + "format" : function(test) { + test.expect(18); + moment.lang('ro'); + var a = [ + ['dddd, MMMM Do YYYY, h:mm:ss A', 'Duminică, Februarie 14 2010, 3:25:50 PM'], + ['ddd, hA', 'Dum, 3PM'], + ['M Mo MM MMMM MMM', '2 2 02 Februarie Feb'], + ['YYYY YY', '2010 10'], + ['D Do DD', '14 14 14'], + ['d do dddd ddd dd', '0 0 Duminică Dum Du'], + ['DDD DDDo DDDD', '45 45 045'], + ['w wo ww', '8 8 08'], + ['h hh', '3 03'], + ['H HH', '15 15'], + ['m mm', '25 25'], + ['s ss', '50 50'], + ['a A', 'pm PM'], + ['\\a DDDo\\a zi \\a \\anului', 'a 45a zi a anului'], + ['L', '14/02/2010'], + ['LL', '14 Februarie 2010'], + ['LLL', '14 Februarie 2010 15:25'], + ['LLLL', 'Duminică, 14 Februarie 2010 15:25'] + ], + b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), + i; + for (i = 0; i < a.length; i++) { + test.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]); + } + test.done(); + }, + + "format ordinal" : function(test) { + test.expect(31); + moment.lang('ro'); + test.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1'); + test.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2'); + test.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3'); + test.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4'); + test.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5'); + test.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6'); + test.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7'); + test.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8'); + test.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9'); + test.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10'); + + test.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11'); + test.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12'); + test.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13'); + test.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14'); + test.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15'); + test.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16'); + test.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17'); + test.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18'); + test.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19'); + test.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20'); + + test.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21'); + test.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22'); + test.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23'); + test.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24'); + test.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25'); + test.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26'); + test.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27'); + test.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28'); + test.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29'); + test.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30'); + + test.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31'); + test.done(); + }, + + "format month" : function(test) { + test.expect(12); + moment.lang('ro'); + var expected = 'Ianuarie Ian_Februarie Feb_Martie Mar_Aprilie Apr_Mai Mai_Iunie Iun_Iulie Iul_August Aug_Septembrie Sep_Octombrie Oct_Noiembrie Noi_Decembrie Dec'.split("_"); + var i; + for (i = 0; i < expected.length; i++) { + test.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]); + } + test.done(); + }, + + "format week" : function(test) { + test.expect(7); + moment.lang('ro'); + var expected = 'Duminică Dum Du_Luni Lun Lu_Marţi Mar Ma_Miercuri Mie Mi_Joi Joi Jo_Vineri Vin Vi_Sâmbătă Sâm Sâ'.split("_"); + var i; + for (i = 0; i < expected.length; i++) { + test.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]); + } + test.done(); + }, + + "from" : function(test) { + test.expect(30); + moment.lang('ro'); + var start = moment([2007, 1, 28]); + test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "câteva secunde", "44 secunde = câteva secunde"); + test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "un minut", "45 secunde = un minut"); + test.equal(start.from(moment([2007, 1, 28]).add({s:89}), true), "un minut", "89 secunde = un minut"); + test.equal(start.from(moment([2007, 1, 28]).add({s:90}), true), "2 minute", "90 secunde = 2 minute"); + test.equal(start.from(moment([2007, 1, 28]).add({m:44}), true), "44 minute", "44 minute = 44 minute"); + test.equal(start.from(moment([2007, 1, 28]).add({m:45}), true), "o oră", "45 minute = o oră"); + test.equal(start.from(moment([2007, 1, 28]).add({m:89}), true), "o oră", "89 minute = o oră"); + test.equal(start.from(moment([2007, 1, 28]).add({m:90}), true), "2 ore", "90 minute = 2 ore"); + test.equal(start.from(moment([2007, 1, 28]).add({h:5}), true), "5 ore", "5 ore = 5 ore"); + test.equal(start.from(moment([2007, 1, 28]).add({h:21}), true), "21 ore", "21 ore = 21 ore"); + test.equal(start.from(moment([2007, 1, 28]).add({h:22}), true), "o zi", "22 ore = o zi"); + test.equal(start.from(moment([2007, 1, 28]).add({h:35}), true), "o zi", "35 ore = o zi"); + test.equal(start.from(moment([2007, 1, 28]).add({h:36}), true), "2 zile", "36 ore = 2 zile"); + test.equal(start.from(moment([2007, 1, 28]).add({d:1}), true), "o zi", "1 zi = o zi"); + test.equal(start.from(moment([2007, 1, 28]).add({d:5}), true), "5 zile", "5 zile = 5 zile"); + test.equal(start.from(moment([2007, 1, 28]).add({d:25}), true), "25 zile", "25 zile = 25 zile"); + test.equal(start.from(moment([2007, 1, 28]).add({d:26}), true), "o lună", "26 zile = o lună"); + test.equal(start.from(moment([2007, 1, 28]).add({d:30}), true), "o lună", "30 zile = o lună"); + test.equal(start.from(moment([2007, 1, 28]).add({d:45}), true), "o lună", "45 zile = o lună"); + test.equal(start.from(moment([2007, 1, 28]).add({d:46}), true), "2 luni", "46 zile = 2 luni"); + test.equal(start.from(moment([2007, 1, 28]).add({d:74}), true), "2 luni", "75 zile = 2 luni"); + test.equal(start.from(moment([2007, 1, 28]).add({d:76}), true), "3 luni", "76 zile = 3 luni"); + test.equal(start.from(moment([2007, 1, 28]).add({M:1}), true), "o lună", "1 lună = o lună"); + test.equal(start.from(moment([2007, 1, 28]).add({M:5}), true), "5 luni", "5 luni = 5 luni"); + test.equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 luni", "344 zile = 11 luni"); + test.equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "un an", "345 zile = un an"); + test.equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "un an", "547 zile = un an"); + test.equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 ani", "548 zile = 2 ani"); + test.equal(start.from(moment([2007, 1, 28]).add({y:1}), true), "un an", "1 an = un an"); + test.equal(start.from(moment([2007, 1, 28]).add({y:5}), true), "5 ani", "5 ani = 5 ani"); + test.done(); + }, + + "suffix" : function(test) { + test.expect(2); + moment.lang('ro'); + test.equal(moment(30000).from(0), "peste câteva secunde", "prefix"); + test.equal(moment(0).from(30000), "câteva secunde în urmă", "suffix"); + test.done(); + }, + + "now from now" : function(test) { + test.expect(1); + moment.lang('ro'); + test.equal(moment().fromNow(), "câteva secunde în urmă", "now from now should display as in the past"); + test.done(); + }, + + "fromNow" : function(test) { + test.expect(2); + moment.lang('ro'); + test.equal(moment().add({s:30}).fromNow(), "peste câteva secunde", "in a few seconds"); + test.equal(moment().add({d:5}).fromNow(), "peste 5 zile", "in 5 days"); + test.done(); + }, + + "calendar day" : function(test) { + test.expect(6); + moment.lang('ro'); + + var a = moment().hours(2).minutes(0).seconds(0); + + test.equal(moment(a).calendar(), "azi la 2:00", "today at the same time"); + test.equal(moment(a).add({ m: 25 }).calendar(), "azi la 2:25", "Now plus 25 min"); + test.equal(moment(a).add({ h: 1 }).calendar(), "azi la 3:00", "Now plus 1 hour"); + test.equal(moment(a).add({ d: 1 }).calendar(), "mâine la 2:00", "tomorrow at the same time"); + test.equal(moment(a).subtract({ h: 1 }).calendar(), "azi la 1:00", "Now minus 1 hour"); + test.equal(moment(a).subtract({ d: 1 }).calendar(), "ieri la 2:00", "yesterday at the same time"); + test.done(); + }, + + "calendar next week" : function(test) { + test.expect(15); + moment.lang('ro'); + + var i; + var m; + + for (i = 2; i < 7; i++) { + m = moment().add({ d: i }); + test.equal(m.calendar(), m.format('dddd [la] LT'), "Today + " + i + " days current time"); + m.hours(0).minutes(0).seconds(0).milliseconds(0); + test.equal(m.calendar(), m.format('dddd [la] LT'), "Today + " + i + " days beginning of day"); + m.hours(23).minutes(59).seconds(59).milliseconds(999); + test.equal(m.calendar(), m.format('dddd [la] LT'), "Today + " + i + " days end of day"); + } + test.done(); + }, + + "calendar last week" : function(test) { + test.expect(15); + moment.lang('ro'); + + for (i = 2; i < 7; i++) { + m = moment().subtract({ d: i }); + test.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), "Today - " + i + " days current time"); + m.hours(0).minutes(0).seconds(0).milliseconds(0); + test.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), "Today - " + i + " days beginning of day"); + m.hours(23).minutes(59).seconds(59).milliseconds(999); + test.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), "Today - " + i + " days end of day"); + } + test.done(); + }, + + "calendar all else" : function(test) { + test.expect(4); + moment.lang('ro'); + var weeksAgo = moment().subtract({ w: 1 }); + var weeksFromNow = moment().add({ w: 1 }); + + test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago"); + test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week"); + + weeksAgo = moment().subtract({ w: 2 }); + weeksFromNow = moment().add({ w: 2 }); + + test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago"); + test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks"); + test.done(); + } +};