Add frontend assets and plugin bundles

Add the legacy frontend themes, scripts, and plugin assets required by the main SPOTA interfaces.
This commit is contained in:
Power BI Dev
2026-05-02 10:09:32 +07:00
parent efdb11db3f
commit a52c2a8462
2061 changed files with 513282 additions and 0 deletions

4
assets/plugins/moment/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
node_modules/
.DS_Store
min/moment+customlangs.js
min/moment+customlangs.min.js

View File

@@ -0,0 +1,5 @@
language: node_js
node_js:
- 0.8
before_script:
- npm install -g grunt-cli

View File

@@ -0,0 +1,45 @@
All pull requests to the `master` branch will be closed.
========================================================
Please submit all pull requests to the `develop` branch.
Language translations will not be merged without unit tests.
============================================================
See [the english unit tests](https://github.com/timrwood/moment/blob/develop/test/lang/en.js) for an example.
Submitting Issues
=================
If you are submitting a bug, please create a [jsfiddle](http://jsfiddle.net/) demonstrating the issue.
Contributing
============
To contribute, fork the library and install grunt.
npm install grunt -g
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 `grunt` to run all tests.
To check the filesize, you can use `grunt size`.
To minify all the files, use `grunt release`.
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 <name>` 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.

View File

@@ -0,0 +1,116 @@
module.exports = function (grunt) {
var embedOption = grunt.option('embed_languages'),
embedLanguageDest = embedOption ?
'min/moment+customlangs.js' :
'min/moment+langs.js',
embedLanguageLangs = 'lang/*.js';
if (embedOption && embedOption.match(/,/)) {
embedLanguageLangs = 'lang/{' + embedOption + '}.js';
}
else if (embedOption) {
embedLanguageLangs = 'lang/' + embedOption + '.js';
}
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat : {
langs: {
src: 'lang/*.js',
dest: 'min/langs.js'
}
},
uglify : {
target: {
files: {
'min/moment+langs.min.js' : 'min/moment+langs.js',
'min/moment+customlangs.min.js' : 'min/moment+customlangs.js',
'min/langs.min.js' : 'min/langs.js',
'min/moment.min.js' : 'moment.js'
}
},
options: {
mangle: true,
compress: {
dead_code: false
},
output: {
ascii_only: true
},
report: 'min',
preserveComments: 'some'
}
},
nodeunit : {
all : ["test/**/*.js"]
},
jshint: {
all: ["Gruntfile.js", "moment.js", "lang/**/*.js", "test/**/*.js"],
options: {
"node" : true,
"browser" : true,
"boss" : false,
"curly" : true,
"debug" : false,
"devel" : false,
"eqeqeq" : true,
"eqnull" : true,
"evil" : false,
"forin" : false,
"immed" : false,
"laxbreak" : false,
"newcap" : true,
"noarg" : true,
"noempty" : false,
"nonew" : false,
"onevar" : true,
"plusplus" : false,
"regexp" : false,
"undef" : true,
"sub" : true,
"strict" : false,
"white" : true,
"globals": {
"define": false
}
}
},
watch : {
test : {
files : [
'moment.js',
'lang/*.js',
'test/**/*.js'
],
tasks: ['nodeunit']
},
jshint : {
files : '<%= jshint.all %>',
tasks: ['jshint']
}
},
embed_languages: {
moment: 'moment.js',
dest: embedLanguageDest,
targetLangs: embedLanguageLangs
}
});
grunt.loadTasks("tasks");
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task.
grunt.registerTask('default', ['jshint', 'nodeunit']);
grunt.registerTask('test', ['nodeunit']);
// Task to be run when releasing a new version
grunt.registerTask('release', ['jshint', 'nodeunit', 'concat',
'embed_languages', 'component', 'uglify']);
};

View File

@@ -0,0 +1,22 @@
Copyright (c) 2011-2013 Tim Wood, Iskren Chernev, Moment.js contributors
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
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.

View File

@@ -0,0 +1,20 @@
{
"name": "moment",
"version": "2.2.1",
"main": "moment.js",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"tasks",
"component.json",
"composer.json",
"CONTRIBUTING.md",
"ender.js",
"Gruntfile.js",
"package.js",
"package.json"
]
}

View File

@@ -0,0 +1,66 @@
{
"name": "moment",
"version": "2.2.1",
"main": "moment.js",
"description": "Parse, validate, manipulate, and display dates in javascript.",
"files": [
"moment.js",
"lang/ar-ma.js",
"lang/ar.js",
"lang/bg.js",
"lang/br.js",
"lang/ca.js",
"lang/cs.js",
"lang/cv.js",
"lang/da.js",
"lang/de.js",
"lang/el.js",
"lang/en-ca.js",
"lang/en-gb.js",
"lang/eo.js",
"lang/es.js",
"lang/et.js",
"lang/eu.js",
"lang/fa.js",
"lang/fi.js",
"lang/fr-ca.js",
"lang/fr.js",
"lang/gl.js",
"lang/he.js",
"lang/hi.js",
"lang/hr.js",
"lang/hu.js",
"lang/id.js",
"lang/is.js",
"lang/it.js",
"lang/ja.js",
"lang/ka.js",
"lang/ko.js",
"lang/lt.js",
"lang/lv.js",
"lang/ml.js",
"lang/mr.js",
"lang/ms-my.js",
"lang/nb.js",
"lang/ne.js",
"lang/nl.js",
"lang/nn.js",
"lang/pl.js",
"lang/pt-br.js",
"lang/pt.js",
"lang/ro.js",
"lang/ru.js",
"lang/sk.js",
"lang/sl.js",
"lang/sq.js",
"lang/sv.js",
"lang/th.js",
"lang/tr.js",
"lang/tzm-la.js",
"lang/tzm.js",
"lang/uk.js",
"lang/vn.js",
"lang/zh-cn.js",
"lang/zh-tw.js"
]
}

View File

@@ -0,0 +1,18 @@
{
"name": "moment/moment",
"description": "Parse, validate, manipulate, and display dates in javascript.",
"keywords": [
"moment",
"date",
"time",
"parse",
"format",
"validate",
"i18n",
"l10n",
"ender"
],
"homepage": "http://github.com/moment/moment/",
"author": "Tim Wood <washwithcare@gmail.com> (http://timwoodcreates.com/)",
"license": "MIT"
}

View File

@@ -0,0 +1 @@
$.ender({ moment: require('moment') })

View File

@@ -0,0 +1,56 @@
// moment.js language configuration
// language : Moroccan Arabic (ar-ma)
// author : ElFadili Yassine : https://github.com/ElFadiliY
// author : Abdel Said : https://github.com/abdelsaid
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('ar-ma', {
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"
},
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 سنوات"
},
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.
}
});
}));

View File

@@ -0,0 +1,56 @@
// moment.js language configuration
// language : Arabic (ar)
// author : Abdel Said : https://github.com/abdelsaid
// changes in months, weekdays : Ahmed Elkhatib
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('ar', {
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"
},
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 سنوات"
},
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.
}
});
}));

View File

@@ -0,0 +1,86 @@
// moment.js language configuration
// language : bulgarian (bg)
// author : Krasen Borisov : https://github.com/kraz
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('bg', {
months : "януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември".split("_"),
monthsShort : "янрев_мар_апрай_юни_юли_авг_сеп_окт_ноеек".split("_"),
weekdays : еделя_понеделник_вторник_срядаетвъртък_петък_събота".split("_"),
weekdaysShort : ед_пон_вто_сря_чет_пет_съб".split("_"),
weekdaysMin : "нд_пн_вт_ср_чт_пт_сб".split("_"),
longDateFormat : {
LT : "h:mm",
L : "D.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 : function () {
switch (this.day()) {
case 0:
case 3:
case 6:
return '[В изминалата] dddd [в] LT';
case 1:
case 2:
case 4:
case 5:
return '[В изминалия] 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 години"
},
ordinal : function (number) {
var lastDigit = number % 10,
last2Digits = number % 100;
if (number === 0) {
return number + '-ев';
} else if (last2Digits === 0) {
return number + '-ен';
} else if (last2Digits > 10 && last2Digits < 20) {
return number + '-ти';
} else if (lastDigit === 1) {
return number + '-ви';
} else if (lastDigit === 2) {
return number + '-ри';
} else if (lastDigit === 7 || lastDigit === 8) {
return number + '-ми';
} else {
return number + '-ти';
}
},
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.
}
});
}));

View File

@@ -0,0 +1,107 @@
// moment.js language configuration
// language : breton (br)
// author : Jean-Baptiste Le Duigou : https://github.com/jbleduigou
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
function relativeTimeWithMutation(number, withoutSuffix, key) {
var format = {
'mm': "munutenn",
'MM': "miz",
'dd': "devezh"
};
return number + ' ' + mutation(format[key], number);
}
function specialMutationForYears(number) {
switch (lastNumber(number)) {
case 1:
case 3:
case 4:
case 5:
case 9:
return number + ' bloaz';
default:
return number + ' vloaz';
}
}
function lastNumber(number) {
if (number > 9) {
return lastNumber(number % 10);
}
return number;
}
function mutation(text, number) {
if (number === 2) {
return softMutation(text);
}
return text;
}
function softMutation(text) {
var mutationTable = {
'm': 'v',
'b': 'v',
'd': 'z'
};
if (mutationTable[text.charAt(0)] === undefined) {
return text;
}
return mutationTable[text.charAt(0)] + text.substring(1);
}
moment.lang('br', {
months : "Genver_C'hwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu".split("_"),
monthsShort : "Gen_C'hwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker".split("_"),
weekdays : "Sul_Lun_Meurzh_Merc'her_Yaou_Gwener_Sadorn".split("_"),
weekdaysShort : "Sul_Lun_Meu_Mer_Yao_Gwe_Sad".split("_"),
weekdaysMin : "Su_Lu_Me_Mer_Ya_Gw_Sa".split("_"),
longDateFormat : {
LT : "h[e]mm A",
L : "DD/MM/YYYY",
LL : "D [a viz] MMMM YYYY",
LLL : "D [a viz] MMMM YYYY LT",
LLLL : "dddd, D [a viz] MMMM YYYY LT"
},
calendar : {
sameDay : '[Hiziv da] LT',
nextDay : '[Warc\'hoazh da] LT',
nextWeek : 'dddd [da] LT',
lastDay : '[Dec\'h da] LT',
lastWeek : 'dddd [paset da] LT',
sameElse : 'L'
},
relativeTime : {
future : "a-benn %s",
past : "%s 'zo",
s : "un nebeud segondennoù",
m : "ur vunutenn",
mm : relativeTimeWithMutation,
h : "un eur",
hh : "%d eur",
d : "un devezh",
dd : relativeTimeWithMutation,
M : "ur miz",
MM : relativeTimeWithMutation,
y : "ur bloaz",
yy : specialMutationForYears
},
ordinal : function (number) {
var output = (number === 1) ? 'añ' : 'vet';
return number + output;
},
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.
}
});
}));

View File

@@ -0,0 +1,66 @@
// moment.js language configuration
// language : catalan (ca)
// author : Juan G. Hurtado : https://github.com/juanghurtado
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('ca', {
months : "Gener_Febrer_Març_Abril_Maig_Juny_Juliol_Agost_Setembre_Octubre_Novembre_Desembre".split("_"),
monthsShort : "Gen._Febr._Mar._Abr._Mai._Jun._Jul._Ag._Set._Oct._Nov._Des.".split("_"),
weekdays : "Diumenge_Dilluns_Dimarts_Dimecres_Dijous_Divendres_Dissabte".split("_"),
weekdaysShort : "Dg._Dl._Dt._Dc._Dj._Dv._Ds.".split("_"),
weekdaysMin : "Dg_Dl_Dt_Dc_Dj_Dv_Ds".split("_"),
longDateFormat : {
LT : "H:mm",
L : "DD/MM/YYYY",
LL : "D MMMM YYYY",
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
calendar : {
sameDay : function () {
return '[avui a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
},
nextDay : function () {
return '[demà a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
},
nextWeek : function () {
return 'dddd [a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
},
lastDay : function () {
return '[ahir a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
},
lastWeek : function () {
return '[el] dddd [passat a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
},
sameElse : 'L'
},
relativeTime : {
future : "en %s",
past : "fa %s",
s : "uns segons",
m : "un minut",
mm : "%d minuts",
h : "una hora",
hh : "%d hores",
d : "un dia",
dd : "%d dies",
M : "un mes",
MM : "%d mesos",
y : "un any",
yy : "%d anys"
},
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.
}
});
}));

View File

@@ -0,0 +1,155 @@
// moment.js language configuration
// language : czech (cs)
// author : petrbela : https://github.com/petrbela
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
var months = "leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec".split("_"),
monthsShort = "led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro".split("_");
function plural(n) {
return (n > 1) && (n < 5) && (~~(n / 10) !== 1);
}
function translate(number, withoutSuffix, key, isFuture) {
var result = number + " ";
switch (key) {
case 's': // a few seconds / in a few seconds / a few seconds ago
return (withoutSuffix || isFuture) ? 'pár vteřin' : 'pár vteřinami';
case 'm': // a minute / in a minute / a minute ago
return withoutSuffix ? 'minuta' : (isFuture ? 'minutu' : 'minutou');
case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
if (withoutSuffix || isFuture) {
return result + (plural(number) ? 'minuty' : 'minut');
} else {
return result + 'minutami';
}
break;
case 'h': // an hour / in an hour / an hour ago
return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
case 'hh': // 9 hours / in 9 hours / 9 hours ago
if (withoutSuffix || isFuture) {
return result + (plural(number) ? 'hodiny' : 'hodin');
} else {
return result + 'hodinami';
}
break;
case 'd': // a day / in a day / a day ago
return (withoutSuffix || isFuture) ? 'den' : 'dnem';
case 'dd': // 9 days / in 9 days / 9 days ago
if (withoutSuffix || isFuture) {
return result + (plural(number) ? 'dny' : 'dní');
} else {
return result + 'dny';
}
break;
case 'M': // a month / in a month / a month ago
return (withoutSuffix || isFuture) ? 'měsíc' : 'měsícem';
case 'MM': // 9 months / in 9 months / 9 months ago
if (withoutSuffix || isFuture) {
return result + (plural(number) ? 'měsíce' : 'měsíců');
} else {
return result + 'měsíci';
}
break;
case 'y': // a year / in a year / a year ago
return (withoutSuffix || isFuture) ? 'rok' : 'rokem';
case 'yy': // 9 years / in 9 years / 9 years ago
if (withoutSuffix || isFuture) {
return result + (plural(number) ? 'roky' : 'let');
} else {
return result + 'lety';
}
break;
}
}
moment.lang('cs', {
months : months,
monthsShort : monthsShort,
monthsParse : (function (months, monthsShort) {
var i, _monthsParse = [];
for (i = 0; i < 12; i++) {
// use custom parser to solve problem with July (červenec)
_monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
}
return _monthsParse;
}(months, monthsShort)),
weekdays : "neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota".split("_"),
weekdaysShort : "ne_po_út_st_čt_pá_so".split("_"),
weekdaysMin : "ne_po_út_st_čt_pá_so".split("_"),
longDateFormat : {
LT: "H:mm",
L : "DD.MM.YYYY",
LL : "D. MMMM YYYY",
LLL : "D. MMMM YYYY LT",
LLLL : "dddd D. MMMM YYYY LT"
},
calendar : {
sameDay: "[dnes v] LT",
nextDay: '[zítra v] LT',
nextWeek: function () {
switch (this.day()) {
case 0:
return '[v neděli v] LT';
case 1:
case 2:
return '[v] dddd [v] LT';
case 3:
return '[ve středu v] LT';
case 4:
return '[ve čtvrtek v] LT';
case 5:
return '[v pátek v] LT';
case 6:
return '[v sobotu v] LT';
}
},
lastDay: '[včera v] LT',
lastWeek: function () {
switch (this.day()) {
case 0:
return '[minulou neděli v] LT';
case 1:
case 2:
return '[minulé] dddd [v] LT';
case 3:
return '[minulou středu v] LT';
case 4:
case 5:
return '[minulý] dddd [v] LT';
case 6:
return '[minulou sobotu v] LT';
}
},
sameElse: "L"
},
relativeTime : {
future : "za %s",
past : "před %s",
s : translate,
m : translate,
mm : translate,
h : translate,
hh : translate,
d : translate,
dd : translate,
M : translate,
MM : translate,
y : translate,
yy : translate
},
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.
}
});
}));

View File

@@ -0,0 +1,59 @@
// moment.js language configuration
// language : chuvash (cv)
// author : Anatoly Mironov : https://github.com/mirontoli
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('cv', {
months : "кăрлач_нарăс_пуш_акаай_çĕртме_утă_çурла_авăн_юпа_чӳк_раштав".split("_"),
monthsShort : "кăрар_пуш_акаай_çĕр_утă_çур_ав_юпа_чӳк_раш".split("_"),
weekdays : "вырсарникун_тунтикун_ытларикун_юнкун_кĕçнерникун_эрнекун_шăматкун".split("_"),
weekdaysShort : "вырун_ытл_юн_кĕç_эрн_шăм".split("_"),
weekdaysMin : р_тн_ыт_юн_кç_эр_шм".split("_"),
longDateFormat : {
LT : "HH:mm",
L : "DD-MM-YYYY",
LL : "YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ]",
LLL : "YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT",
LLLL : "dddd, YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT"
},
calendar : {
sameDay: '[Паян] LT [сехетре]',
nextDay: '[Ыран] LT [сехетре]',
lastDay: '[Ĕнер] LT [сехетре]',
nextWeek: '[Çитес] dddd LT [сехетре]',
lastWeek: '[Иртнĕ] dddd LT [сехетре]',
sameElse: 'L'
},
relativeTime : {
future : function (output) {
var affix = /сехет$/i.exec(output) ? "рен" : /çул$/i.exec(output) ? "тан" : "ран";
return output + affix;
},
past : "%s каялла",
s : "пĕр-ик çеккунт",
m : "пĕр минут",
mm : "%d минут",
h : "пĕр сехет",
hh : "%d сехет",
d : "пĕр кун",
dd : "%d кун",
M : "пĕр уйăх",
MM : "%d уйăх",
y : "пĕр çул",
yy : "%d çул"
},
ordinal : '%d-мĕш',
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.
}
});
}));

View File

@@ -0,0 +1,56 @@
// moment.js language configuration
// language : danish (da)
// author : Ulrik Nielsen : https://github.com/mrbase
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('da', {
months : "januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december".split("_"),
monthsShort : "jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),
weekdays : "søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),
weekdaysShort : "søn_man_tir_ons_tor_fre_lør".split("_"),
weekdaysMin : "sø_ma_ti_on_to_fr_lø".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 : '[I dag kl.] LT',
nextDay : '[I morgen kl.] LT',
nextWeek : 'dddd [kl.] LT',
lastDay : '[I går kl.] LT',
lastWeek : '[sidste] dddd [kl] LT',
sameElse : 'L'
},
relativeTime : {
future : "om %s",
past : "%s siden",
s : "få sekunder",
m : "et minut",
mm : "%d minutter",
h : "en time",
hh : "%d timer",
d : "en dag",
dd : "%d dage",
M : "en måned",
MM : "%d måneder",
y : "et år",
yy : "%d år"
},
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.
}
});
}));

View File

@@ -0,0 +1,71 @@
// moment.js language configuration
// language : german (de)
// author : lluchs : https://github.com/lluchs
// author: Menelion Elensúle: https://github.com/Oire
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
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];
}
moment.lang('de', {
months : "Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),
monthsShort : "Jan._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: "H: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.
}
});
}));

View File

@@ -0,0 +1,79 @@
// moment.js language configuration
// language : modern greek (el)
// author : Aggelos Karalias : https://github.com/mehiel
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('el', {
monthsNominativeEl : "Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος".split("_"),
monthsGenitiveEl : "Ιανουαρίου_Φεβρουαρίου_Μαρτίου_Απριλίου_Μαΐου_Ιουνίου_Ιουλίου_Αυγούστου_Σεπτεμβρίου_Οκτωβρίου_Νοεμβρίου_Δεκεμβρίου".split("_"),
months : function (momentToFormat, format) {
if (/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()];
}
},
monthsShort : "Ιαν_Φεβ_Μαρ_Απρ_Μαϊ_Ιουν_Ιουλ_Αυγ_Σεπ_Οκτ_Νοε_Δεκ".split("_"),
weekdays : "Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο".split("_"),
weekdaysShort : "Κυρ_Δευ_Τρι_Τετ_Πεμ_Παραβ".split("_"),
weekdaysMin : "Κυ_Δε_Τρ_Τε_Πε_Παα".split("_"),
meridiem : function (hours, minutes, isLower) {
if (hours > 11) {
return isLower ? 'μμ' : 'ΜΜ';
} else {
return isLower ? 'πμ' : 'ΠΜ';
}
},
longDateFormat : {
LT : "h:mm A",
L : "DD/MM/YYYY",
LL : "D MMMM YYYY",
LLL : "D MMMM YYYY LT",
LLLL : "dddd, D MMMM YYYY LT"
},
calendarEl : {
sameDay : '[Σήμερα {}] LT',
nextDay : '[Αύριο {}] LT',
nextWeek : 'dddd [{}] LT',
lastDay : '[Χθες {}] LT',
lastWeek : '[την προηγούμενη] dddd [{}] LT',
sameElse : 'L'
},
calendar : function (key, mom) {
var output = this._calendarEl[key],
hours = mom && mom.hours();
return output.replace("{}", (hours % 12 === 1 ? "στη" : "στις"));
},
relativeTime : {
future : "σε %s",
past : "%s πριν",
s : "δευτερόλεπτα",
m : "ένα λεπτό",
mm : "%d λεπτά",
h : "μία ώρα",
hh : "%d ώρες",
d : "μία μέρα",
dd : "%d μέρες",
M : "ένας μήνας",
MM : "%d μήνες",
y : "ένας χρόνος",
yy : "%d χρόνια"
},
ordinal : function (number) {
return number + 'η';
},
week : {
dow : 1, // Monday is the first day of the week.
doy : 4 // The week that contains Jan 4st is the first week of the year.
}
});
}));

View File

@@ -0,0 +1,59 @@
// moment.js language configuration
// language : canadian english (en-ca)
// author : Jonathan Abourbih : https://github.com/jonbca
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('en-ca', {
months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),
weekdaysMin : "Su_Mo_Tu_We_Th_Fr_Sa".split("_"),
longDateFormat : {
LT : "h:mm A",
L : "YYYY-MM-DD",
LL : "D MMMM, YYYY",
LLL : "D MMMM, YYYY LT",
LLLL : "dddd, D MMMM, YYYY LT"
},
calendar : {
sameDay : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
nextWeek : 'dddd [at] LT',
lastDay : '[Yesterday at] LT',
lastWeek : '[Last] dddd [at] LT',
sameElse : 'L'
},
relativeTime : {
future : "in %s",
past : "%s ago",
s : "a few seconds",
m : "a minute",
mm : "%d minutes",
h : "an hour",
hh : "%d hours",
d : "a day",
dd : "%d days",
M : "a month",
MM : "%d months",
y : "a year",
yy : "%d years"
},
ordinal : function (number) {
var b = number % 10,
output = (~~ (number % 100 / 10) === 1) ? 'th' :
(b === 1) ? 'st' :
(b === 2) ? 'nd' :
(b === 3) ? 'rd' : 'th';
return number + output;
}
});
}));

View File

@@ -0,0 +1,63 @@
// moment.js language configuration
// language : great britain english (en-gb)
// author : Chris Gedrim : https://github.com/chrisgedrim
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('en-gb', {
months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),
weekdaysMin : "Su_Mo_Tu_We_Th_Fr_Sa".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 : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
nextWeek : 'dddd [at] LT',
lastDay : '[Yesterday at] LT',
lastWeek : '[Last] dddd [at] LT',
sameElse : 'L'
},
relativeTime : {
future : "in %s",
past : "%s ago",
s : "a few seconds",
m : "a minute",
mm : "%d minutes",
h : "an hour",
hh : "%d hours",
d : "a day",
dd : "%d days",
M : "a month",
MM : "%d months",
y : "a year",
yy : "%d years"
},
ordinal : function (number) {
var b = number % 10,
output = (~~ (number % 100 / 10) === 1) ? 'th' :
(b === 1) ? 'st' :
(b === 2) ? 'nd' :
(b === 3) ? 'rd' : 'th';
return number + output;
},
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.
}
});
}));

View File

@@ -0,0 +1,65 @@
// moment.js language configuration
// language : esperanto (eo)
// author : Colin Dean : https://github.com/colindean
// komento: Mi estas malcerta se mi korekte traktis akuzativojn en tiu traduko.
// Se ne, bonvolu korekti kaj avizi min por ke mi povas lerni!
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('eo', {
months : "januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro".split("_"),
monthsShort : "jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec".split("_"),
weekdays : "Dimanĉo_Lundo_Mardo_Merkredo_Ĵaŭdo_Vendredo_Sabato".split("_"),
weekdaysShort : "Dim_Lun_Mard_Merk_Ĵaŭ_Ven_Sab".split("_"),
weekdaysMin : "Di_Lu_Ma_Me_Ĵa_Ve_Sa".split("_"),
longDateFormat : {
LT : "HH:mm",
L : "YYYY-MM-DD",
LL : "D[-an de] MMMM, YYYY",
LLL : "D[-an de] MMMM, YYYY LT",
LLLL : "dddd, [la] D[-an de] MMMM, YYYY LT"
},
meridiem : function (hours, minutes, isLower) {
if (hours > 11) {
return isLower ? 'p.t.m.' : 'P.T.M.';
} else {
return isLower ? 'a.t.m.' : 'A.T.M.';
}
},
calendar : {
sameDay : '[Hodiaŭ je] LT',
nextDay : '[Morgaŭ je] LT',
nextWeek : 'dddd [je] LT',
lastDay : '[Hieraŭ je] LT',
lastWeek : '[pasinta] dddd [je] LT',
sameElse : 'L'
},
relativeTime : {
future : "je %s",
past : "antaŭ %s",
s : "sekundoj",
m : "minuto",
mm : "%d minutoj",
h : "horo",
hh : "%d horoj",
d : "tago",//ne 'diurno', ĉar estas uzita por proksimumo
dd : "%d tagoj",
M : "monato",
MM : "%d monatoj",
y : "jaro",
yy : "%d jaroj"
},
ordinal : "%da",
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.
}
});
}));

View File

@@ -0,0 +1,66 @@
// moment.js language configuration
// language : spanish (es)
// author : Julio Napurí : https://github.com/julionc
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('es', {
months : "enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),
monthsShort : "ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.".split("_"),
weekdays : "domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),
weekdaysShort : "dom._lun._mar._mié._jue._vie._sáb.".split("_"),
weekdaysMin : "Do_Lu_Ma_Mi_Ju_Vi_Sá".split("_"),
longDateFormat : {
LT : "H:mm",
L : "DD/MM/YYYY",
LL : "D [de] MMMM [de] YYYY",
LLL : "D [de] MMMM [de] YYYY LT",
LLLL : "dddd, D [de] MMMM [de] YYYY LT"
},
calendar : {
sameDay : function () {
return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
},
nextDay : function () {
return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
},
nextWeek : function () {
return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
},
lastDay : function () {
return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
},
lastWeek : function () {
return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
},
sameElse : 'L'
},
relativeTime : {
future : "en %s",
past : "hace %s",
s : "unos segundos",
m : "un minuto",
mm : "%d minutos",
h : "una hora",
hh : "%d horas",
d : "un día",
dd : "%d días",
M : "un mes",
MM : "%d meses",
y : "un año",
yy : "%d años"
},
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.
}
});
}));

View File

@@ -0,0 +1,60 @@
// moment.js language configuration
// language : estonian (et)
// author : Henry Kehlmann : https://github.com/madhenry
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
function translateSeconds(number, withoutSuffix, key, isFuture) {
return (isFuture || withoutSuffix) ? 'paari sekundi' : 'paar sekundit';
}
moment.lang('et', {
months : "jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember".split("_"),
monthsShort : "jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets".split("_"),
weekdays : "pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev".split("_"),
weekdaysShort : "P_E_T_K_N_R_L".split("_"),
weekdaysMin : "P_E_T_K_N_R_L".split("_"),
longDateFormat : {
LT : "H:mm",
L : "DD.MM.YYYY",
LL : "D. MMMM YYYY",
LLL : "D. MMMM YYYY LT",
LLLL : "dddd, D. MMMM YYYY LT"
},
calendar : {
sameDay : '[Täna,] LT',
nextDay : '[Homme,] LT',
nextWeek : '[Järgmine] dddd LT',
lastDay : '[Eile,] LT',
lastWeek : '[Eelmine] dddd LT',
sameElse : 'L'
},
relativeTime : {
future : "%s pärast",
past : "%s tagasi",
s : translateSeconds,
m : "minut",
mm : "%d minutit",
h : "tund",
hh : "%d tundi",
d : "päev",
dd : "%d päeva",
M : "kuu",
MM : "%d kuud",
y : "aasta",
yy : "%d aastat"
},
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.
}
});
}));

View File

@@ -0,0 +1,60 @@
// moment.js language configuration
// language : euskara (eu)
// author : Eneko Illarramendi : https://github.com/eillarra
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('eu', {
months : "urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua".split("_"),
monthsShort : "urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.".split("_"),
weekdays : "igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata".split("_"),
weekdaysShort : "ig._al._ar._az._og._ol._lr.".split("_"),
weekdaysMin : "ig_al_ar_az_og_ol_lr".split("_"),
longDateFormat : {
LT : "HH:mm",
L : "YYYY-MM-DD",
LL : "YYYY[ko] MMMM[ren] D[a]",
LLL : "YYYY[ko] MMMM[ren] D[a] LT",
LLLL : "dddd, YYYY[ko] MMMM[ren] D[a] LT",
l : "YYYY-M-D",
ll : "YYYY[ko] MMM D[a]",
lll : "YYYY[ko] MMM D[a] LT",
llll : "ddd, YYYY[ko] MMM D[a] LT"
},
calendar : {
sameDay : '[gaur] LT[etan]',
nextDay : '[bihar] LT[etan]',
nextWeek : 'dddd LT[etan]',
lastDay : '[atzo] LT[etan]',
lastWeek : '[aurreko] dddd LT[etan]',
sameElse : 'L'
},
relativeTime : {
future : "%s barru",
past : "duela %s",
s : "segundo batzuk",
m : "minutu bat",
mm : "%d minutu",
h : "ordu bat",
hh : "%d ordu",
d : "egun bat",
dd : "%d egun",
M : "hilabete bat",
MM : "%d hilabete",
y : "urte bat",
yy : "%d urte"
},
ordinal : '%d.',
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.
}
});
}));

View File

@@ -0,0 +1,97 @@
// moment.js language configuration
// language : Persian Language
// author : Ebrahim Byagowi : https://github.com/ebraminio
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
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'
};
moment.lang('fa', {
months : انویه_فوریهارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
monthsShort : انویه_فوریهارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
weekdays : 'یک\u200cشنبه_دوشنبهه\u200cشنبههارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
weekdaysShort : 'یک\u200cشنبه_دوشنبهه\u200cشنبههارشنبه_پنج\u200cشنبه_جمعه_شنبه'.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, '،');
},
ordinal : '%dم',
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.
}
});
}));

View File

@@ -0,0 +1,103 @@
// moment.js language configuration
// language : finnish (fi)
// author : Tarmo Aidantausta : https://github.com/bleadof
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
var numbers_past = 'nolla yksi kaksi kolme neljä viisi kuusi seitsemän kahdeksan yhdeksän'.split(' '),
numbers_future = ['nolla', 'yhden', 'kahden', 'kolmen', 'neljän', 'viiden', 'kuuden',
numbers_past[7], numbers_past[8], numbers_past[9]];
function translate(number, withoutSuffix, key, isFuture) {
var result = "";
switch (key) {
case 's':
return isFuture ? 'muutaman sekunnin' : 'muutama sekunti';
case 'm':
return isFuture ? 'minuutin' : 'minuutti';
case 'mm':
result = isFuture ? 'minuutin' : 'minuuttia';
break;
case 'h':
return isFuture ? 'tunnin' : 'tunti';
case 'hh':
result = isFuture ? 'tunnin' : 'tuntia';
break;
case 'd':
return isFuture ? 'päivän' : 'päivä';
case 'dd':
result = isFuture ? 'päivän' : 'päivää';
break;
case 'M':
return isFuture ? 'kuukauden' : 'kuukausi';
case 'MM':
result = isFuture ? 'kuukauden' : 'kuukautta';
break;
case 'y':
return isFuture ? 'vuoden' : 'vuosi';
case 'yy':
result = isFuture ? 'vuoden' : 'vuotta';
break;
}
result = verbal_number(number, isFuture) + " " + result;
return result;
}
function verbal_number(number, isFuture) {
return number < 10 ? (isFuture ? numbers_future[number] : numbers_past[number]) : number;
}
moment.lang('fi', {
months : "tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu".split("_"),
monthsShort : "tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu".split("_"),
weekdays : "sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai".split("_"),
weekdaysShort : "su_ma_ti_ke_to_pe_la".split("_"),
weekdaysMin : "su_ma_ti_ke_to_pe_la".split("_"),
longDateFormat : {
LT : "HH.mm",
L : "DD.MM.YYYY",
LL : "Do MMMM[ta] YYYY",
LLL : "Do MMMM[ta] YYYY, [klo] LT",
LLLL : "dddd, Do MMMM[ta] YYYY, [klo] LT",
l : "D.M.YYYY",
ll : "Do MMM YYYY",
lll : "Do MMM YYYY, [klo] LT",
llll : "ddd, Do MMM YYYY, [klo] LT"
},
calendar : {
sameDay : '[tänään] [klo] LT',
nextDay : '[huomenna] [klo] LT',
nextWeek : 'dddd [klo] LT',
lastDay : '[eilen] [klo] LT',
lastWeek : '[viime] dddd[na] [klo] LT',
sameElse : 'L'
},
relativeTime : {
future : "%s päästä",
past : "%s sitten",
s : translate,
m : translate,
mm : translate,
h : translate,
hh : translate,
d : translate,
dd : translate,
M : translate,
MM : translate,
y : translate,
yy : translate
},
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.
}
});
}));

View File

@@ -0,0 +1,54 @@
// moment.js language configuration
// language : canadian french (fr-ca)
// author : Jonathan Abourbih : https://github.com/jonbca
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('fr-ca', {
months : "janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),
monthsShort : "janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),
weekdays : "dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),
weekdaysShort : "dim._lun._mar._mer._jeu._ven._sam.".split("_"),
weekdaysMin : "Di_Lu_Ma_Me_Je_Ve_Sa".split("_"),
longDateFormat : {
LT : "HH:mm",
L : "YYYY-MM-DD",
LL : "D MMMM YYYY",
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
calendar : {
sameDay: "[Aujourd'hui à] LT",
nextDay: '[Demain à] LT',
nextWeek: 'dddd [à] LT',
lastDay: '[Hier à] LT',
lastWeek: 'dddd [dernier à] LT',
sameElse: 'L'
},
relativeTime : {
future : "dans %s",
past : "il y a %s",
s : "quelques secondes",
m : "une minute",
mm : "%d minutes",
h : "une heure",
hh : "%d heures",
d : "un jour",
dd : "%d jours",
M : "un mois",
MM : "%d mois",
y : "un an",
yy : "%d ans"
},
ordinal : function (number) {
return number + (number === 1 ? 'er' : '');
}
});
}));

View File

@@ -0,0 +1,58 @@
// moment.js language configuration
// language : french (fr)
// author : John Fischer : https://github.com/jfroffice
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('fr', {
months : "janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),
monthsShort : "janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),
weekdays : "dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),
weekdaysShort : "dim._lun._mar._mer._jeu._ven._sam.".split("_"),
weekdaysMin : "Di_Lu_Ma_Me_Je_Ve_Sa".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: "[Aujourd'hui à] LT",
nextDay: '[Demain à] LT',
nextWeek: 'dddd [à] LT',
lastDay: '[Hier à] LT',
lastWeek: 'dddd [dernier à] LT',
sameElse: 'L'
},
relativeTime : {
future : "dans %s",
past : "il y a %s",
s : "quelques secondes",
m : "une minute",
mm : "%d minutes",
h : "une heure",
hh : "%d heures",
d : "un jour",
dd : "%d jours",
M : "un mois",
MM : "%d mois",
y : "un an",
yy : "%d ans"
},
ordinal : function (number) {
return number + (number === 1 ? 'er' : '');
},
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.
}
});
}));

View File

@@ -0,0 +1,71 @@
// moment.js language configuration
// language : galician (gl)
// author : Juan G. Hurtado : https://github.com/juanghurtado
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('gl', {
months : "Xaneiro_Febreiro_Marzo_Abril_Maio_Xuño_Xullo_Agosto_Setembro_Outubro_Novembro_Decembro".split("_"),
monthsShort : "Xan._Feb._Mar._Abr._Mai._Xuñ._Xul._Ago._Set._Out._Nov._Dec.".split("_"),
weekdays : "Domingo_Luns_Martes_Mércores_Xoves_Venres_Sábado".split("_"),
weekdaysShort : "Dom._Lun._Mar._Mér._Xov._Ven._Sáb.".split("_"),
weekdaysMin : "Do_Lu_Ma_Mé_Xo_Ve_Sá".split("_"),
longDateFormat : {
LT : "H:mm",
L : "DD/MM/YYYY",
LL : "D MMMM YYYY",
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
calendar : {
sameDay : function () {
return '[hoxe ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
},
nextDay : function () {
return '[mañá ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
},
nextWeek : function () {
return 'dddd [' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
},
lastDay : function () {
return '[onte ' + ((this.hours() !== 1) ? 'á' : 'a') + '] LT';
},
lastWeek : function () {
return '[o] dddd [pasado ' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
},
sameElse : 'L'
},
relativeTime : {
future : function (str) {
if (str === "uns segundos") {
return "nuns segundos";
}
return "en " + str;
},
past : "hai %s",
s : "uns segundos",
m : "un minuto",
mm : "%d minutos",
h : "unha hora",
hh : "%d horas",
d : "un día",
dd : "%d días",
M : "un mes",
MM : "%d meses",
y : "un ano",
yy : "%d anos"
},
ordinal : '%dº',
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.
}
});
}));

View File

@@ -0,0 +1,77 @@
// moment.js language configuration
// language : Hebrew (he)
// author : Tomer Cohen : https://github.com/tomer
// author : Moshe Simantov : https://github.com/DevelopmentIL
// author : Tal Ater : https://github.com/TalAter
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('he', {
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",
l : "D/M/YYYY",
ll : "D MMM YYYY",
lll : "D MMM YYYY LT",
llll : "ddd, D MMM 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 : function (number) {
if (number === 2) {
return "שעתיים";
}
return number + " שעות";
},
d : "יום",
dd : function (number) {
if (number === 2) {
return "יומיים";
}
return number + " ימים";
},
M : "חודש",
MM : function (number) {
if (number === 2) {
return "חודשיים";
}
return number + " חודשים";
},
y : "שנה",
yy : function (number) {
if (number === 2) {
return "שנתיים";
}
return number + " שנים";
}
}
});
}));

View File

@@ -0,0 +1,105 @@
// moment.js language configuration
// language : hindi (hi)
// author : Mayank Singhal : https://github.com/mayanksinghal
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
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'
};
moment.lang('hi', {
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];
});
},
// Hindi 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 Hindi.
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.
}
});
}));

View File

@@ -0,0 +1,140 @@
// moment.js language configuration
// language : hrvatski (hr)
// author : Bojan Marković : https://github.com/bmarkovic
// based on (sl) translation by Robert Sedovšek
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
function translate(number, withoutSuffix, key) {
var result = number + " ";
switch (key) {
case 'm':
return withoutSuffix ? 'jedna minuta' : 'jedne minute';
case 'mm':
if (number === 1) {
result += 'minuta';
} else if (number === 2 || number === 3 || number === 4) {
result += 'minute';
} else {
result += 'minuta';
}
return result;
case 'h':
return withoutSuffix ? 'jedan sat' : 'jednog sata';
case 'hh':
if (number === 1) {
result += 'sat';
} else if (number === 2 || number === 3 || number === 4) {
result += 'sata';
} else {
result += 'sati';
}
return result;
case 'dd':
if (number === 1) {
result += 'dan';
} else {
result += 'dana';
}
return result;
case 'MM':
if (number === 1) {
result += 'mjesec';
} else if (number === 2 || number === 3 || number === 4) {
result += 'mjeseca';
} else {
result += 'mjeseci';
}
return result;
case 'yy':
if (number === 1) {
result += 'godina';
} else if (number === 2 || number === 3 || number === 4) {
result += 'godine';
} else {
result += 'godina';
}
return result;
}
}
moment.lang('hr', {
months : "sječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac".split("_"),
monthsShort : "sje._vel._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.".split("_"),
weekdays : "nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),
weekdaysShort : "ned._pon._uto._sri._čet._pet._sub.".split("_"),
weekdaysMin : "ne_po_ut_sr_če_pe_su".split("_"),
longDateFormat : {
LT : "H:mm",
L : "DD. MM. YYYY",
LL : "D. MMMM YYYY",
LLL : "D. MMMM YYYY LT",
LLLL : "dddd, D. MMMM YYYY LT"
},
calendar : {
sameDay : '[danas u] LT',
nextDay : '[sutra u] LT',
nextWeek : function () {
switch (this.day()) {
case 0:
return '[u] [nedjelju] [u] LT';
case 3:
return '[u] [srijedu] [u] LT';
case 6:
return '[u] [subotu] [u] LT';
case 1:
case 2:
case 4:
case 5:
return '[u] dddd [u] LT';
}
},
lastDay : '[jučer u] LT',
lastWeek : function () {
switch (this.day()) {
case 0:
case 3:
return '[prošlu] dddd [u] LT';
case 6:
return '[prošle] [subote] [u] LT';
case 1:
case 2:
case 4:
case 5:
return '[prošli] dddd [u] LT';
}
},
sameElse : 'L'
},
relativeTime : {
future : "za %s",
past : "prije %s",
s : "par sekundi",
m : translate,
mm : translate,
h : translate,
hh : translate,
d : "dan",
dd : translate,
M : "mjesec",
MM : translate,
y : "godinu",
yy : translate
},
ordinal : '%d.',
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.
}
});
}));

View File

@@ -0,0 +1,97 @@
// moment.js language configuration
// language : hungarian (hu)
// author : Adam Brunner : https://github.com/adambrunner
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
var weekEndings = 'vasárnap hétfőn kedden szerdán csütörtökön pénteken szombaton'.split(' ');
function translate(number, withoutSuffix, key, isFuture) {
var num = number,
suffix;
switch (key) {
case 's':
return (isFuture || withoutSuffix) ? 'néhány másodperc' : 'néhány másodperce';
case 'm':
return 'egy' + (isFuture || withoutSuffix ? ' perc' : ' perce');
case 'mm':
return num + (isFuture || withoutSuffix ? ' perc' : ' perce');
case 'h':
return 'egy' + (isFuture || withoutSuffix ? ' óra' : ' órája');
case 'hh':
return num + (isFuture || withoutSuffix ? ' óra' : ' órája');
case 'd':
return 'egy' + (isFuture || withoutSuffix ? ' nap' : ' napja');
case 'dd':
return num + (isFuture || withoutSuffix ? ' nap' : ' napja');
case 'M':
return 'egy' + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
case 'MM':
return num + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
case 'y':
return 'egy' + (isFuture || withoutSuffix ? ' év' : ' éve');
case 'yy':
return num + (isFuture || withoutSuffix ? ' év' : ' éve');
}
return '';
}
function week(isFuture) {
return (isFuture ? '' : '[múlt] ') + '[' + weekEndings[this.day()] + '] LT[-kor]';
}
moment.lang('hu', {
months : "január_február_március_április_május_június_július_augusztus_szeptember_október_november_december".split("_"),
monthsShort : "jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec".split("_"),
weekdays : "vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat".split("_"),
weekdaysShort : "v_h_k_sze_cs_p_szo".split("_"),
longDateFormat : {
LT : "H:mm",
L : "YYYY.MM.DD.",
LL : "YYYY. MMMM D.",
LLL : "YYYY. MMMM D., LT",
LLLL : "YYYY. MMMM D., dddd LT"
},
calendar : {
sameDay : '[ma] LT[-kor]',
nextDay : '[holnap] LT[-kor]',
nextWeek : function () {
return week.call(this, true);
},
lastDay : '[tegnap] LT[-kor]',
lastWeek : function () {
return week.call(this, false);
},
sameElse : 'L'
},
relativeTime : {
future : "%s múlva",
past : "%s",
s : translate,
m : translate,
mm : translate,
h : translate,
hh : translate,
d : translate,
dd : translate,
M : translate,
MM : translate,
y : translate,
yy : translate
},
ordinal : '%d.',
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.
}
});
}));

View File

@@ -0,0 +1,67 @@
// moment.js language configuration
// language : Bahasa Indonesia (id)
// author : Mohammad Satrio Utomo : https://github.com/tyok
// reference: http://id.wikisource.org/wiki/Pedoman_Umum_Ejaan_Bahasa_Indonesia_yang_Disempurnakan
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('id', {
months : "Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember".split("_"),
monthsShort : "Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nov_Des".split("_"),
weekdays : "Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu".split("_"),
weekdaysShort : "Min_Sen_Sel_Rab_Kam_Jum_Sab".split("_"),
weekdaysMin : "Mg_Sn_Sl_Rb_Km_Jm_Sb".split("_"),
longDateFormat : {
LT : "HH.mm",
L : "DD/MM/YYYY",
LL : "D MMMM YYYY",
LLL : "D MMMM YYYY [pukul] LT",
LLLL : "dddd, D MMMM YYYY [pukul] LT"
},
meridiem : function (hours, minutes, isLower) {
if (hours < 11) {
return 'pagi';
} else if (hours < 15) {
return 'siang';
} else if (hours < 19) {
return 'sore';
} else {
return 'malam';
}
},
calendar : {
sameDay : '[Hari ini pukul] LT',
nextDay : '[Besok pukul] LT',
nextWeek : 'dddd [pukul] LT',
lastDay : '[Kemarin pukul] LT',
lastWeek : 'dddd [lalu pukul] LT',
sameElse : 'L'
},
relativeTime : {
future : "dalam %s",
past : "%s yang lalu",
s : "beberapa detik",
m : "semenit",
mm : "%d menit",
h : "sejam",
hh : "%d jam",
d : "sehari",
dd : "%d hari",
M : "sebulan",
MM : "%d bulan",
y : "setahun",
yy : "%d tahun"
},
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.
}
});
}));

View File

@@ -0,0 +1,124 @@
// moment.js language configuration
// language : icelandic (is)
// author : Hinrik Örn Sigurðsson : https://github.com/hinrik
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
function plural(n) {
if (n % 100 === 11) {
return true;
} else if (n % 10 === 1) {
return false;
}
return true;
}
function translate(number, withoutSuffix, key, isFuture) {
var result = number + " ";
switch (key) {
case 's':
return withoutSuffix || isFuture ? 'nokkrar sekúndur' : 'nokkrum sekúndum';
case 'm':
return withoutSuffix ? 'mínúta' : 'mínútu';
case 'mm':
if (plural(number)) {
return result + (withoutSuffix || isFuture ? 'mínútur' : 'mínútum');
} else if (withoutSuffix) {
return result + 'mínúta';
}
return result + 'mínútu';
case 'hh':
if (plural(number)) {
return result + (withoutSuffix || isFuture ? 'klukkustundir' : 'klukkustundum');
}
return result + 'klukkustund';
case 'd':
if (withoutSuffix) {
return 'dagur';
}
return isFuture ? 'dag' : 'degi';
case 'dd':
if (plural(number)) {
if (withoutSuffix) {
return result + 'dagar';
}
return result + (isFuture ? 'daga' : 'dögum');
} else if (withoutSuffix) {
return result + 'dagur';
}
return result + (isFuture ? 'dag' : 'degi');
case 'M':
if (withoutSuffix) {
return 'mánuður';
}
return isFuture ? 'mánuð' : 'mánuði';
case 'MM':
if (plural(number)) {
if (withoutSuffix) {
return result + 'mánuðir';
}
return result + (isFuture ? 'mánuði' : 'mánuðum');
} else if (withoutSuffix) {
return result + 'mánuður';
}
return result + (isFuture ? 'mánuð' : 'mánuði');
case 'y':
return withoutSuffix || isFuture ? 'ár' : 'ári';
case 'yy':
if (plural(number)) {
return result + (withoutSuffix || isFuture ? 'ár' : 'árum');
}
return result + (withoutSuffix || isFuture ? 'ár' : 'ári');
}
}
moment.lang('is', {
months : "janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember".split("_"),
monthsShort : "jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des".split("_"),
weekdays : "sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur".split("_"),
weekdaysShort : "sun_mán_þri_mið_fim_fös_lau".split("_"),
weekdaysMin : "Su_Má_Þr_Mi_Fi_Fö_La".split("_"),
longDateFormat : {
LT : "H:mm",
L : "DD/MM/YYYY",
LL : "D. MMMM YYYY",
LLL : "D. MMMM YYYY [kl.] LT",
LLLL : "dddd, D. MMMM YYYY [kl.] LT"
},
calendar : {
sameDay : '[í dag kl.] LT',
nextDay : '[á morgun kl.] LT',
nextWeek : 'dddd [kl.] LT',
lastDay : '[í gær kl.] LT',
lastWeek : '[síðasta] dddd [kl.] LT',
sameElse : 'L'
},
relativeTime : {
future : "eftir %s",
past : "fyrir %s síðan",
s : translate,
m : translate,
mm : translate,
h : "klukkustund",
hh : translate,
d : translate,
dd : translate,
M : translate,
MM : translate,
y : translate,
yy : translate
},
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.
}
});
}));

View File

@@ -0,0 +1,59 @@
// moment.js language configuration
// language : italian (it)
// author : Lorenzo : https://github.com/aliem
// author: Mattia Larentis: https://github.com/nostalgiaz
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
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("_"),
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("_"),
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: '[Oggi alle] LT',
nextDay: '[Domani alle] LT',
nextWeek: 'dddd [alle] LT',
lastDay: '[Ieri alle] LT',
lastWeek: '[lo scorso] dddd [alle] LT',
sameElse: 'L'
},
relativeTime : {
future : function (s) {
return ((/^[0-9].+$/).test(s) ? "tra" : "in") + " " + s;
},
past : "%s fa",
s : "secondi",
m : "un minuto",
mm : "%d minuti",
h : "un'ora",
hh : "%d ore",
d : "un giorno",
dd : "%d giorni",
M : "un mese",
MM : "%d mesi",
y : "un anno",
yy : "%d anni"
},
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.
}
});
}));

View File

@@ -0,0 +1,58 @@
// moment.js language configuration
// language : japanese (ja)
// author : LI Long : https://github.com/baryon
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('ja', {
months : "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
monthsShort : "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
weekdays : "日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日".split("_"),
weekdaysShort : "日_月_火_水_木_金_土".split("_"),
weekdaysMin : "日_月_火_水_木_金_土".split("_"),
longDateFormat : {
LT : "Ah時m分",
L : "YYYY/MM/DD",
LL : "YYYY年M月D日",
LLL : "YYYY年M月D日LT",
LLLL : "YYYY年M月D日LT dddd"
},
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 : "1分",
mm : "%d分",
h : "1時間",
hh : "%d時間",
d : "1日",
dd : "%d日",
M : "1ヶ月",
MM : "%dヶ月",
y : "1年",
yy : "%d年"
}
});
}));

View File

@@ -0,0 +1,108 @@
// moment.js language configuration
// language : Georgian (ka)
// author : Irakli Janiashvili : https://github.com/irakli-janiashvili
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
function monthsCaseReplace(m, format) {
var months = {
'nominative': 'იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი'.split('_'),
'accusative': 'იანვარს_თებერვალს_მარტს_აპრილის_მაისს_ივნისს_ივლისს_აგვისტს_სექტემბერს_ოქტომბერს_ნოემბერს_დეკემბერს'.split('_')
},
nounCase = (/D[oD] *MMMM?/).test(format) ?
'accusative' :
'nominative';
return months[nounCase][m.month()];
}
function weekdaysCaseReplace(m, format) {
var weekdays = {
'nominative': 'კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი'.split('_'),
'accusative': 'კვირას_ორშაბათს_სამშაბათს_ოთხშაბათს_ხუთშაბათს_პარასკევს_შაბათს'.split('_')
},
nounCase = (/(წინა|შემდეგ)/).test(format) ?
'accusative' :
'nominative';
return weekdays[nounCase][m.day()];
}
moment.lang('ka', {
months : monthsCaseReplace,
monthsShort : "იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ".split("_"),
weekdays : weekdaysCaseReplace,
weekdaysShort : "კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ".split("_"),
weekdaysMin : "კვ_ორ_სა_ოთ_ხუ_პა_შა".split("_"),
longDateFormat : {
LT : "h:mm A",
L : "DD/MM/YYYY",
LL : "D MMMM YYYY",
LLL : "D MMMM YYYY LT",
LLLL : "dddd, D MMMM YYYY LT"
},
calendar : {
sameDay : '[დღეს] LT[-ზე]',
nextDay : '[ხვალ] LT[-ზე]',
lastDay : '[გუშინ] LT[-ზე]',
nextWeek : '[შემდეგ] dddd LT[-ზე]',
lastWeek : '[წინა] dddd LT-ზე',
sameElse : 'L'
},
relativeTime : {
future : function (s) {
return (/(წამი|წუთი|საათი|წელი)/).test(s) ?
s.replace(/ი$/, "ში") :
s + "ში";
},
past : function (s) {
if ((/(წამი|წუთი|საათი|დღე|თვე)/).test(s)) {
return s.replace(/(ი|ე)$/, "ის წინ");
}
if ((/წელი/).test(s)) {
return s.replace(/წელი$/, "წლის წინ");
}
},
s : "რამდენიმე წამი",
m : "წუთი",
mm : "%d წუთი",
h : "საათი",
hh : "%d საათი",
d : "დღე",
dd : "%d დღე",
M : "თვე",
MM : "%d თვე",
y : "წელი",
yy : "%d წელი"
},
ordinal : function (number) {
if (number === 0) {
return number;
}
if (number === 1) {
return number + "-ლი";
}
if ((number < 20) || (number <= 100 && (number % 20 === 0)) || (number % 100 === 0)) {
return "მე-" + number;
}
return number + "-ე";
},
week : {
dow : 1,
doy : 7
}
});
}));

View File

@@ -0,0 +1,56 @@
// moment.js language configuration
// language : korean (ko)
// author : Kyungwook, Park : https://github.com/kyungw00k
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('ko', {
months : "1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),
monthsShort : "1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),
weekdays : "일요일_월요일_화요일_수요일_목요일_금요일_토요일".split("_"),
weekdaysShort : "일_월_화_수_목_금_토".split("_"),
weekdaysMin : "일_월_화_수_목_금_토".split("_"),
longDateFormat : {
LT : "A h시 mm분",
L : "YYYY.MM.DD",
LL : "YYYY년 MMMM D일",
LLL : "YYYY년 MMMM D일 LT",
LLLL : "YYYY년 MMMM D일 dddd LT"
},
meridiem : function (hour, minute, isUpper) {
return hour < 12 ? '오전' : '오후';
},
calendar : {
sameDay : '오늘 LT',
nextDay : '내일 LT',
nextWeek : 'dddd LT',
lastDay : '어제 LT',
lastWeek : '지난주 dddd LT',
sameElse : 'L'
},
relativeTime : {
future : "%s 후",
past : "%s 전",
s : "몇초",
ss : "%d초",
m : "일분",
mm : "%d분",
h : "한시간",
hh : "%d시간",
d : "하루",
dd : "%d일",
M : "한달",
MM : "%d달",
y : "일년",
yy : "%d년"
},
ordinal : '%d일'
});
}));

View File

@@ -0,0 +1,109 @@
// moment.js language configuration
// language : Lithuanian (lt)
// author : Mindaugas Mozūras : https://github.com/mmozuras
var units = {
"m" : "minutė_minutės_minutę",
"mm": "minutės_minučių_minutes",
"h" : "valanda_valandos_valandą",
"hh": "valandos_valandų_valandas",
"d" : "diena_dienos_dieną",
"dd": "dienos_dienų_dienas",
"M" : "mėnuo_mėnesio_mėnesį",
"MM": "mėnesiai_mėnesių_mėnesius",
"y" : "metai_metų_metus",
"yy": "metai_metų_metus"
};
function translateSeconds(number, withoutSuffix, key, isFuture) {
if (withoutSuffix) {
return "kelios sekundės";
} else {
return isFuture ? "kelių sekundžių" : "kelias sekundes";
}
}
function translateSingular(number, withoutSuffix, key, isFuture) {
return withoutSuffix ? forms(key)[0] : (isFuture ? forms(key)[1] : forms(key)[2]);
}
function special(number) {
return number % 10 === 0 || (number > 10 && number < 20);
}
function forms(key) {
return units[key].split("_");
}
function translate(number, withoutSuffix, key, isFuture) {
var result = number + " ";
if (number === 1) {
return result + translateSingular(number, withoutSuffix, key[0], isFuture);
} else if (withoutSuffix) {
return result + (special(number) ? forms(key)[1] : forms(key)[0]);
} else {
if (isFuture) {
return result + forms(key)[1];
} else {
return result + (special(number) ? forms(key)[1] : forms(key)[2]);
}
}
}
var weekDays = "pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis_sekmadienis".split("_");
function relativeWeekDay(moment, format) {
var nominative = format.indexOf('dddd LT') === -1,
weekDay = weekDays[moment.weekday()];
return nominative ? weekDay : weekDay.substring(0, weekDay.length - 2) + "į";
}
require("../moment").lang("lt", {
months : "sausio_vasario_kovo_balandžio_gegužės_biržėlio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio".split("_"),
monthsShort : "sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd".split("_"),
weekdays : relativeWeekDay,
weekdaysShort : "Sek_Pir_Ant_Tre_Ket_Pen_Šeš".split("_"),
weekdaysMin : "S_P_A_T_K_Pn_Š".split("_"),
longDateFormat : {
LT : "HH:mm",
L : "YYYY-MM-DD",
LL : "YYYY [m.] MMMM D [d.]",
LLL : "YYYY [m.] MMMM D [d.], LT [val.]",
LLLL : "YYYY [m.] MMMM D [d.], dddd, LT [val.]",
l : "YYYY-MM-DD",
ll : "YYYY [m.] MMMM D [d.]",
lll : "YYYY [m.] MMMM D [d.], LT [val.]",
llll : "YYYY [m.] MMMM D [d.], ddd, LT [val.]"
},
calendar : {
sameDay : "[Šiandien] LT",
nextDay : "[Rytoj] LT",
nextWeek : "dddd LT",
lastDay : "[Vakar] LT",
lastWeek : "[Praėjusį] dddd LT",
sameElse : "L"
},
relativeTime : {
future : "po %s",
past : "prieš %s",
s : translateSeconds,
m : translateSingular,
mm : translate,
h : translateSingular,
hh : translate,
d : translateSingular,
dd : translate,
M : translateSingular,
MM : translate,
y : translateSingular,
yy : translate
},
ordinal : function (number) {
return number + '-oji';
},
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.
}
});

View File

@@ -0,0 +1,77 @@
// moment.js language configuration
// language : latvian (lv)
// author : Kristaps Karlsons : https://github.com/skakri
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
var units = {
'mm': 'minūti_minūtes_minūte_minūtes',
'hh': 'stundu_stundas_stunda_stundas',
'dd': 'dienu_dienas_diena_dienas',
'MM': 'mēnesi_mēnešus_mēnesis_mēneši',
'yy': 'gadu_gadus_gads_gadi'
};
function format(word, number, withoutSuffix) {
var forms = word.split('_');
if (withoutSuffix) {
return number % 10 === 1 && number !== 11 ? forms[2] : forms[3];
} else {
return number % 10 === 1 && number !== 11 ? forms[0] : forms[1];
}
}
function relativeTimeWithPlural(number, withoutSuffix, key) {
return number + ' ' + format(units[key], number, withoutSuffix);
}
moment.lang('lv', {
months : "janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris".split("_"),
monthsShort : "jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec".split("_"),
weekdays : "svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena".split("_"),
weekdaysShort : "Sv_P_O_T_C_Pk_S".split("_"),
weekdaysMin : "Sv_P_O_T_C_Pk_S".split("_"),
longDateFormat : {
LT : "HH:mm",
L : "DD.MM.YYYY",
LL : "YYYY. [gada] D. MMMM",
LLL : "YYYY. [gada] D. MMMM, LT",
LLLL : "YYYY. [gada] D. MMMM, dddd, LT"
},
calendar : {
sameDay : '[Šodien pulksten] LT',
nextDay : '[Rīt pulksten] LT',
nextWeek : 'dddd [pulksten] LT',
lastDay : '[Vakar pulksten] LT',
lastWeek : '[Pagājušā] dddd [pulksten] LT',
sameElse : 'L'
},
relativeTime : {
future : "%s vēlāk",
past : "%s agrāk",
s : "dažas sekundes",
m : "minūti",
mm : relativeTimeWithPlural,
h : "stundu",
hh : relativeTimeWithPlural,
d : "dienu",
dd : relativeTimeWithPlural,
M : "mēnesi",
MM : relativeTimeWithPlural,
y : "gadu",
yy : relativeTimeWithPlural
},
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.
}
});
}));

View File

@@ -0,0 +1,64 @@
// moment.js language configuration
// language : malayalam (ml)
// author : Floyd Pink : https://github.com/floydpink
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('ml', {
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 വർഷം"
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return "രാത്രി";
} else if (hour < 12) {
return "രാവിലെ";
} else if (hour < 17) {
return "ഉച്ച കഴിഞ്ഞ്";
} else if (hour < 20) {
return "വൈകുന്നേരം";
} else {
return "രാത്രി";
}
}
});
}));

View File

@@ -0,0 +1,104 @@
// moment.js language configuration
// language : Marathi (mr)
// author : Harshad Kale : https://github.com/kalehv
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
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'
};
moment.lang('mr', {
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];
});
},
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.
}
});
}));

View File

@@ -0,0 +1,66 @@
// moment.js language configuration
// language : Bahasa Malaysia (ms-MY)
// author : Weldan Jamili : https://github.com/weldan
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('ms-my', {
months : "Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember".split("_"),
monthsShort : "Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis".split("_"),
weekdays : "Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu".split("_"),
weekdaysShort : "Ahd_Isn_Sel_Rab_Kha_Jum_Sab".split("_"),
weekdaysMin : "Ah_Is_Sl_Rb_Km_Jm_Sb".split("_"),
longDateFormat : {
LT : "HH.mm",
L : "DD/MM/YYYY",
LL : "D MMMM YYYY",
LLL : "D MMMM YYYY [pukul] LT",
LLLL : "dddd, D MMMM YYYY [pukul] LT"
},
meridiem : function (hours, minutes, isLower) {
if (hours < 11) {
return 'pagi';
} else if (hours < 15) {
return 'tengahari';
} else if (hours < 19) {
return 'petang';
} else {
return 'malam';
}
},
calendar : {
sameDay : '[Hari ini pukul] LT',
nextDay : '[Esok pukul] LT',
nextWeek : 'dddd [pukul] LT',
lastDay : '[Kelmarin pukul] LT',
lastWeek : 'dddd [lepas pukul] LT',
sameElse : 'L'
},
relativeTime : {
future : "dalam %s",
past : "%s yang lepas",
s : "beberapa saat",
m : "seminit",
mm : "%d minit",
h : "sejam",
hh : "%d jam",
d : "sehari",
dd : "%d hari",
M : "sebulan",
MM : "%d bulan",
y : "setahun",
yy : "%d tahun"
},
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.
}
});
}));

View File

@@ -0,0 +1,57 @@
// moment.js language configuration
// language : norwegian bokmål (nb)
// authors : Espen Hovlandsdal : https://github.com/rexxars
// Sigurd Gartmann : https://github.com/sigurdga
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('nb', {
months : "januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),
monthsShort : "jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.".split("_"),
weekdays : "søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),
weekdaysShort : "sø._ma._ti._on._to._fr._lø.".split("_"),
weekdaysMin : "sø_ma_ti_on_to_fr_lø".split("_"),
longDateFormat : {
LT : "H.mm",
L : "DD.MM.YYYY",
LL : "D. MMMM YYYY",
LLL : "D. MMMM YYYY [kl.] LT",
LLLL : "dddd D. MMMM YYYY [kl.] LT"
},
calendar : {
sameDay: '[i dag kl.] LT',
nextDay: '[i morgen kl.] LT',
nextWeek: 'dddd [kl.] LT',
lastDay: '[i går kl.] LT',
lastWeek: '[forrige] dddd [kl.] LT',
sameElse: 'L'
},
relativeTime : {
future : "om %s",
past : "for %s siden",
s : "noen sekunder",
m : "ett minutt",
mm : "%d minutter",
h : "en time",
hh : "%d timer",
d : "en dag",
dd : "%d dager",
M : "en måned",
MM : "%d måneder",
y : "ett år",
yy : "%d år"
},
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.
}
});
}));

View File

@@ -0,0 +1,105 @@
// moment.js language configuration
// language : nepali/nepalese
// author : suvash : https://github.com/suvash
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
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'
};
moment.lang('ne', {
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"
},
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];
});
},
meridiem : function (hour, minute, isLower) {
if (hour < 3) {
return "राती";
} else if (hour < 10) {
return "बिहान";
} else if (hour < 15) {
return "दिउँसो";
} else if (hour < 18) {
return "बेलुका";
} else if (hour < 20) {
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 बर्ष"
},
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.
}
});
}));

View File

@@ -0,0 +1,67 @@
// moment.js language configuration
// language : dutch (nl)
// author : Joris Röling : https://github.com/jjupiter
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
var monthsShortWithDots = "jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.".split("_"),
monthsShortWithoutDots = "jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec".split("_");
moment.lang('nl', {
months : "januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),
monthsShort : function (m, format) {
if (/-MMM-/.test(format)) {
return monthsShortWithoutDots[m.month()];
} else {
return monthsShortWithDots[m.month()];
}
},
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("_"),
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: '[vandaag om] LT',
nextDay: '[morgen om] LT',
nextWeek: 'dddd [om] LT',
lastDay: '[gisteren om] LT',
lastWeek: '[afgelopen] dddd [om] LT',
sameElse: 'L'
},
relativeTime : {
future : "over %s",
past : "%s geleden",
s : "een paar seconden",
m : "één minuut",
mm : "%d minuten",
h : "één uur",
hh : "%d uur",
d : "één dag",
dd : "%d dagen",
M : "één maand",
MM : "%d maanden",
y : "één jaar",
yy : "%d jaar"
},
ordinal : function (number) {
return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
},
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.
}
});
}));

View File

@@ -0,0 +1,56 @@
// moment.js language configuration
// language : norwegian nynorsk (nn)
// author : https://github.com/mechuwind
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('nn', {
months : "januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),
monthsShort : "jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),
weekdays : "sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag".split("_"),
weekdaysShort : "sun_mån_tys_ons_tor_fre_lau".split("_"),
weekdaysMin : "su_må_ty_on_to_fr_lø".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: '[I dag klokka] LT',
nextDay: '[I morgon klokka] LT',
nextWeek: 'dddd [klokka] LT',
lastDay: '[I går klokka] LT',
lastWeek: '[Føregående] dddd [klokka] LT',
sameElse: 'L'
},
relativeTime : {
future : "om %s",
past : "for %s siden",
s : "noen sekund",
m : "ett minutt",
mm : "%d minutt",
h : "en time",
hh : "%d timar",
d : "en dag",
dd : "%d dagar",
M : "en månad",
MM : "%d månader",
y : "ett år",
yy : "%d år"
},
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.
}
});
}));

View File

@@ -0,0 +1,98 @@
// moment.js language configuration
// language : polish (pl)
// author : Rafal Hirsz : https://github.com/evoL
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
var monthsNominative = "styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"),
monthsSubjective = "stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia".split("_");
function plural(n) {
return (n % 10 < 5) && (n % 10 > 1) && (~~(n / 10) !== 1);
}
function translate(number, withoutSuffix, key) {
var result = number + " ";
switch (key) {
case 'm':
return withoutSuffix ? 'minuta' : 'minutę';
case 'mm':
return result + (plural(number) ? 'minuty' : 'minut');
case 'h':
return withoutSuffix ? 'godzina' : 'godzinę';
case 'hh':
return result + (plural(number) ? 'godziny' : 'godzin');
case 'MM':
return result + (plural(number) ? 'miesiące' : 'miesięcy');
case 'yy':
return result + (plural(number) ? 'lata' : 'lat');
}
}
moment.lang('pl', {
months : function (momentToFormat, format) {
if (/D MMMM/.test(format)) {
return monthsSubjective[momentToFormat.month()];
} else {
return monthsNominative[momentToFormat.month()];
}
},
monthsShort : "sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"),
weekdays : "niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"),
weekdaysShort : "nie_pon_wt_śr_czw_pt_sb".split("_"),
weekdaysMin : "N_Pn_Wt_Śr_Cz_Pt_So".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: '[Dziś o] LT',
nextDay: '[Jutro o] LT',
nextWeek: '[W] dddd [o] LT',
lastDay: '[Wczoraj o] LT',
lastWeek: function () {
switch (this.day()) {
case 0:
return '[W zeszłą niedzielę o] LT';
case 3:
return '[W zeszłą środę o] LT';
case 6:
return '[W zeszłą sobotę o] LT';
default:
return '[W zeszły] dddd [o] LT';
}
},
sameElse: 'L'
},
relativeTime : {
future : "za %s",
past : "%s temu",
s : "kilka sekund",
m : translate,
mm : translate,
h : translate,
hh : translate,
d : "1 dzień",
dd : '%d dni',
M : "miesiąc",
MM : translate,
y : "rok",
yy : translate
},
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.
}
});
}));

View File

@@ -0,0 +1,56 @@
// moment.js language configuration
// language : brazilian portuguese (pt-br)
// author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('pt-br', {
months : "Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro".split("_"),
monthsShort : "Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),
weekdays : "Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado".split("_"),
weekdaysShort : "Dom_Seg_Ter_Qua_Qui_Sex_Sáb".split("_"),
weekdaysMin : "Dom_2ª_3ª_4ª_5ª_6ª_Sáb".split("_"),
longDateFormat : {
LT : "HH:mm",
L : "DD/MM/YYYY",
LL : "D [de] MMMM [de] YYYY",
LLL : "D [de] MMMM [de] YYYY LT",
LLLL : "dddd, D [de] MMMM [de] YYYY LT"
},
calendar : {
sameDay: '[Hoje às] LT',
nextDay: '[Amanhã às] LT',
nextWeek: 'dddd [às] LT',
lastDay: '[Ontem às] LT',
lastWeek: function () {
return (this.day() === 0 || this.day() === 6) ?
'[Último] dddd [às] LT' : // Saturday + Sunday
'[Última] dddd [às] LT'; // Monday - Friday
},
sameElse: 'L'
},
relativeTime : {
future : "em %s",
past : "%s atrás",
s : "segundos",
m : "um minuto",
mm : "%d minutos",
h : "uma hora",
hh : "%d horas",
d : "um dia",
dd : "%d dias",
M : "um mês",
MM : "%d meses",
y : "um ano",
yy : "%d anos"
},
ordinal : '%dº'
});
}));

View File

@@ -0,0 +1,60 @@
// moment.js language configuration
// language : portuguese (pt)
// author : Jefferson : https://github.com/jalex79
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('pt', {
months : "Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro".split("_"),
monthsShort : "Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),
weekdays : "Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado".split("_"),
weekdaysShort : "Dom_Seg_Ter_Qua_Qui_Sex_Sáb".split("_"),
weekdaysMin : "Dom_2ª_3ª_4ª_5ª_6ª_Sáb".split("_"),
longDateFormat : {
LT : "HH:mm",
L : "DD/MM/YYYY",
LL : "D [de] MMMM [de] YYYY",
LLL : "D [de] MMMM [de] YYYY LT",
LLLL : "dddd, D [de] MMMM [de] YYYY LT"
},
calendar : {
sameDay: '[Hoje às] LT',
nextDay: '[Amanhã às] LT',
nextWeek: 'dddd [às] LT',
lastDay: '[Ontem às] LT',
lastWeek: function () {
return (this.day() === 0 || this.day() === 6) ?
'[Último] dddd [às] LT' : // Saturday + Sunday
'[Última] dddd [às] LT'; // Monday - Friday
},
sameElse: 'L'
},
relativeTime : {
future : "em %s",
past : "%s atrás",
s : "segundos",
m : "um minuto",
mm : "%d minutos",
h : "uma hora",
hh : "%d horas",
d : "um dia",
dd : "%d dias",
M : "um mês",
MM : "%d meses",
y : "um ano",
yy : "%d anos"
},
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.
}
});
}));

View File

@@ -0,0 +1,56 @@
// moment.js language configuration
// language : romanian (ro)
// author : Vlad Gurdiga : https://github.com/gurdiga
// author : Valentin Agachi : https://github.com/avaly
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('ro', {
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"
},
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.
}
});
}));

View File

@@ -0,0 +1,163 @@
// moment.js language configuration
// language : russian (ru)
// author : Viktorminator : https://github.com/Viktorminator
// Author : Menelion Elensúle : https://github.com/Oire
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
function plural(word, num) {
var forms = word.split('_');
return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
}
function relativeTimeWithPlural(number, withoutSuffix, key) {
var format = {
'mm': 'минута_минуты_минут',
'hh': асасаасов',
'dd': ень_дня_дней',
'MM': есяц_месяцаесяцев',
'yy': 'год_годает'
};
if (key === 'm') {
return withoutSuffix ? 'минута' : 'минуту';
}
else {
return number + ' ' + plural(format[key], +number);
}
}
function monthsCaseReplace(m, format) {
var months = {
'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
},
nounCase = (/D[oD]? *MMMM?/).test(format) ?
'accusative' :
'nominative';
return months[nounCase][m.month()];
}
function monthsShortCaseReplace(m, format) {
var monthsShort = {
'nominative': 'янв_фев_мар_апрай_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
'accusative': 'янв_фев_мар_апрая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
},
nounCase = (/D[oD]? *MMMM?/).test(format) ?
'accusative' :
'nominative';
return monthsShort[nounCase][m.month()];
}
function weekdaysCaseReplace(m, format) {
var weekdays = {
'nominative': оскресенье_понедельник_вторник_средаетверг_пятница_суббота'.split('_'),
'accusative': оскресенье_понедельник_вторник_средуетверг_пятницу_субботу'.split('_')
},
nounCase = (/\[ ?[Вв] ?(?:прошлую|следующую)? ?\] ?dddd/).test(format) ?
'accusative' :
'nominative';
return weekdays[nounCase][m.day()];
}
moment.lang('ru', {
months : monthsCaseReplace,
monthsShort : monthsShortCaseReplace,
weekdays : weekdaysCaseReplace,
weekdaysShort : с_пн_вт_ср_чт_пт_сб".split("_"),
weekdaysMin : с_пн_вт_ср_чт_пт_сб".split("_"),
monthsParse : [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[й|я]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i],
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: '[Сегодня в] LT',
nextDay: '[Завтра в] LT',
lastDay: '[Вчера в] LT',
nextWeek: function () {
return this.day() === 2 ? '[Во] dddd [в] LT' : '[В] dddd [в] LT';
},
lastWeek: function () {
switch (this.day()) {
case 0:
return '[В прошлое] dddd [в] LT';
case 1:
case 2:
case 4:
return '[В прошлый] dddd [в] LT';
case 3:
case 5:
case 6:
return '[В прошлую] dddd [в] LT';
}
},
sameElse: 'L'
},
relativeTime : {
future : "через %s",
past : "%s назад",
s : "несколько секунд",
m : relativeTimeWithPlural,
mm : relativeTimeWithPlural,
h : "час",
hh : relativeTimeWithPlural,
d : "день",
dd : relativeTimeWithPlural,
M : "месяц",
MM : relativeTimeWithPlural,
y : "год",
yy : relativeTimeWithPlural
},
// M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return "ночи";
} else if (hour < 12) {
return "утра";
} else if (hour < 17) {
return "дня";
} else {
return "вечера";
}
},
ordinal: function (number, period) {
switch (period) {
case 'M':
case 'd':
case 'DDD':
return number + '-й';
case 'D':
return number + '-го';
case 'w':
case 'W':
return number + '-я';
default:
return number;
}
},
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.
}
});
}));

View File

@@ -0,0 +1,156 @@
// moment.js language configuration
// language : slovak (sk)
// author : Martin Minka : https://github.com/k2s
// based on work of petrbela : https://github.com/petrbela
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
var months = "január_február_marec_apríl_máj_jún_júl_august_september_október_november_december".split("_"),
monthsShort = "jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec".split("_");
function plural(n) {
return (n > 1) && (n < 5);
}
function translate(number, withoutSuffix, key, isFuture) {
var result = number + " ";
switch (key) {
case 's': // a few seconds / in a few seconds / a few seconds ago
return (withoutSuffix || isFuture) ? 'pár sekúnd' : 'pár sekundami';
case 'm': // a minute / in a minute / a minute ago
return withoutSuffix ? 'minúta' : (isFuture ? 'minútu' : 'minútou');
case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
if (withoutSuffix || isFuture) {
return result + (plural(number) ? 'minúty' : 'minút');
} else {
return result + 'minútami';
}
break;
case 'h': // an hour / in an hour / an hour ago
return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
case 'hh': // 9 hours / in 9 hours / 9 hours ago
if (withoutSuffix || isFuture) {
return result + (plural(number) ? 'hodiny' : 'hodín');
} else {
return result + 'hodinami';
}
break;
case 'd': // a day / in a day / a day ago
return (withoutSuffix || isFuture) ? 'deň' : 'dňom';
case 'dd': // 9 days / in 9 days / 9 days ago
if (withoutSuffix || isFuture) {
return result + (plural(number) ? 'dni' : 'dní');
} else {
return result + 'dňami';
}
break;
case 'M': // a month / in a month / a month ago
return (withoutSuffix || isFuture) ? 'mesiac' : 'mesiacom';
case 'MM': // 9 months / in 9 months / 9 months ago
if (withoutSuffix || isFuture) {
return result + (plural(number) ? 'mesiace' : 'mesiacov');
} else {
return result + 'mesiacmi';
}
break;
case 'y': // a year / in a year / a year ago
return (withoutSuffix || isFuture) ? 'rok' : 'rokom';
case 'yy': // 9 years / in 9 years / 9 years ago
if (withoutSuffix || isFuture) {
return result + (plural(number) ? 'roky' : 'rokov');
} else {
return result + 'rokmi';
}
break;
}
}
moment.lang('sk', {
months : months,
monthsShort : monthsShort,
monthsParse : (function (months, monthsShort) {
var i, _monthsParse = [];
for (i = 0; i < 12; i++) {
// use custom parser to solve problem with July (červenec)
_monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
}
return _monthsParse;
}(months, monthsShort)),
weekdays : "nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota".split("_"),
weekdaysShort : "ne_po_ut_st_št_pi_so".split("_"),
weekdaysMin : "ne_po_ut_st_št_pi_so".split("_"),
longDateFormat : {
LT: "H:mm",
L : "DD.MM.YYYY",
LL : "D. MMMM YYYY",
LLL : "D. MMMM YYYY LT",
LLLL : "dddd D. MMMM YYYY LT"
},
calendar : {
sameDay: "[dnes o] LT",
nextDay: '[zajtra o] LT',
nextWeek: function () {
switch (this.day()) {
case 0:
return '[v nedeľu o] LT';
case 1:
case 2:
return '[v] dddd [o] LT';
case 3:
return '[v stredu o] LT';
case 4:
return '[vo štvrtok o] LT';
case 5:
return '[v piatok o] LT';
case 6:
return '[v sobotu o] LT';
}
},
lastDay: '[včera o] LT',
lastWeek: function () {
switch (this.day()) {
case 0:
return '[minulú nedeľu o] LT';
case 1:
case 2:
return '[minulý] dddd [o] LT';
case 3:
return '[minulú stredu o] LT';
case 4:
case 5:
return '[minulý] dddd [o] LT';
case 6:
return '[minulú sobotu o] LT';
}
},
sameElse: "L"
},
relativeTime : {
future : "za %s",
past : "pred %s",
s : translate,
m : translate,
mm : translate,
h : translate,
hh : translate,
d : translate,
dd : translate,
M : translate,
MM : translate,
y : translate,
yy : translate
},
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.
}
});
}));

View File

@@ -0,0 +1,144 @@
// moment.js language configuration
// language : slovenian (sl)
// author : Robert Sedovšek : https://github.com/sedovsek
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
function translate(number, withoutSuffix, key) {
var result = number + " ";
switch (key) {
case 'm':
return withoutSuffix ? 'ena minuta' : 'eno minuto';
case 'mm':
if (number === 1) {
result += 'minuta';
} else if (number === 2) {
result += 'minuti';
} else if (number === 3 || number === 4) {
result += 'minute';
} else {
result += 'minut';
}
return result;
case 'h':
return withoutSuffix ? 'ena ura' : 'eno uro';
case 'hh':
if (number === 1) {
result += 'ura';
} else if (number === 2) {
result += 'uri';
} else if (number === 3 || number === 4) {
result += 'ure';
} else {
result += 'ur';
}
return result;
case 'dd':
if (number === 1) {
result += 'dan';
} else {
result += 'dni';
}
return result;
case 'MM':
if (number === 1) {
result += 'mesec';
} else if (number === 2) {
result += 'meseca';
} else if (number === 3 || number === 4) {
result += 'mesece';
} else {
result += 'mesecev';
}
return result;
case 'yy':
if (number === 1) {
result += 'leto';
} else if (number === 2) {
result += 'leti';
} else if (number === 3 || number === 4) {
result += 'leta';
} else {
result += 'let';
}
return result;
}
}
moment.lang('sl', {
months : "januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december".split("_"),
monthsShort : "jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.".split("_"),
weekdays : "nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota".split("_"),
weekdaysShort : "ned._pon._tor._sre._čet._pet._sob.".split("_"),
weekdaysMin : "ne_po_to_sr_če_pe_so".split("_"),
longDateFormat : {
LT : "H:mm",
L : "DD. MM. YYYY",
LL : "D. MMMM YYYY",
LLL : "D. MMMM YYYY LT",
LLLL : "dddd, D. MMMM YYYY LT"
},
calendar : {
sameDay : '[danes ob] LT',
nextDay : '[jutri ob] LT',
nextWeek : function () {
switch (this.day()) {
case 0:
return '[v] [nedeljo] [ob] LT';
case 3:
return '[v] [sredo] [ob] LT';
case 6:
return '[v] [soboto] [ob] LT';
case 1:
case 2:
case 4:
case 5:
return '[v] dddd [ob] LT';
}
},
lastDay : '[včeraj ob] LT',
lastWeek : function () {
switch (this.day()) {
case 0:
case 3:
case 6:
return '[prejšnja] dddd [ob] LT';
case 1:
case 2:
case 4:
case 5:
return '[prejšnji] dddd [ob] LT';
}
},
sameElse : 'L'
},
relativeTime : {
future : "čez %s",
past : "%s nazaj",
s : "nekaj sekund",
m : translate,
mm : translate,
h : translate,
hh : translate,
d : "en dan",
dd : translate,
M : "en mesec",
MM : translate,
y : "eno leto",
yy : translate
},
ordinal : '%d.',
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.
}
});
}));

View File

@@ -0,0 +1,57 @@
// moment.js language configuration
// language : Albanian (sq)
// author : Flakërim Ismani : https://github.com/flakerimi
// author: Menelion Elensúle: https://github.com/Oire (tests)
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('sq', {
months : "Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor".split("_"),
monthsShort : "Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj".split("_"),
weekdays : "E Diel_E Hënë_E Marte_E Mërkure_E Enjte_E Premte_E Shtunë".split("_"),
weekdaysShort : "Die_Hën_Mar_Mër_Enj_Pre_Sht".split("_"),
weekdaysMin : "D_H_Ma_Më_E_P_Sh".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 : '[Sot në] LT',
nextDay : '[Neser në] LT',
nextWeek : 'dddd [në] LT',
lastDay : '[Dje në] LT',
lastWeek : 'dddd [e kaluar në] LT',
sameElse : 'L'
},
relativeTime : {
future : "në %s",
past : "%s me parë",
s : "disa seconda",
m : "një minut",
mm : "%d minutea",
h : "një orë",
hh : "%d orë",
d : "një ditë",
dd : "%d ditë",
M : "një muaj",
MM : "%d muaj",
y : "një vit",
yy : "%d vite"
},
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.
}
});
}));

View File

@@ -0,0 +1,63 @@
// moment.js language configuration
// language : swedish (sv)
// author : Jens Alm : https://github.com/ulmus
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('sv', {
months : "januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),
monthsShort : "jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),
weekdays : "söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),
weekdaysShort : "sön_mån_tis_ons_tor_fre_lör".split("_"),
weekdaysMin : "sö_må_ti_on_to_fr_lö".split("_"),
longDateFormat : {
LT : "HH:mm",
L : "YYYY-MM-DD",
LL : "D MMMM YYYY",
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
calendar : {
sameDay: '[Idag] LT',
nextDay: '[Imorgon] LT',
lastDay: '[Igår] LT',
nextWeek: 'dddd LT',
lastWeek: '[Förra] dddd[en] LT',
sameElse: 'L'
},
relativeTime : {
future : "om %s",
past : "för %s sedan",
s : "några sekunder",
m : "en minut",
mm : "%d minuter",
h : "en timme",
hh : "%d timmar",
d : "en dag",
dd : "%d dagar",
M : "en månad",
MM : "%d månader",
y : "ett år",
yy : "%d år"
},
ordinal : function (number) {
var b = number % 10,
output = (~~ (number % 100 / 10) === 1) ? 'e' :
(b === 1) ? 'a' :
(b === 2) ? 'a' :
(b === 3) ? 'e' : 'e';
return number + output;
},
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.
}
});
}));

View File

@@ -0,0 +1,58 @@
// moment.js language configuration
// language : thai (th)
// author : Kridsada Thanabulpong : https://github.com/sirn
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('th', {
months : "มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม".split("_"),
monthsShort : "มกรา_กุมภา_มีนา_เมษา_พฤษภา_มิถุนา_กรกฎา_สิงหา_กันยา_ตุลา_พฤศจิกา_ธันวา".split("_"),
weekdays : "อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์".split("_"),
weekdaysShort : "อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์".split("_"), // yes, three characters difference
weekdaysMin : "อา._จ._อ._พ._พฤ._ศ._ส.".split("_"),
longDateFormat : {
LT : "H นาฬิกา m นาที",
L : "YYYY/MM/DD",
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 : "1 นาที",
mm : "%d นาที",
h : "1 ชั่วโมง",
hh : "%d ชั่วโมง",
d : "1 วัน",
dd : "%d วัน",
M : "1 เดือน",
MM : "%d เดือน",
y : "1 ปี",
yy : "%d ปี"
}
});
}));

View File

@@ -0,0 +1,93 @@
// moment.js language configuration
// language : turkish (tr)
// authors : Erhan Gundogan : https://github.com/erhangundogan,
// Burak Yiğit Kaya: https://github.com/BYK
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
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ı"
};
moment.lang('tr', {
months : "Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık".split("_"),
monthsShort : "Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara".split("_"),
weekdays : "Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi".split("_"),
weekdaysShort : "Paz_Pts_Sal_Çar_Per_Cum_Cts".split("_"),
weekdaysMin : "Pz_Pt_Sa_Ça_Pe_Cu_Ct".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 : '[yarın saat] LT',
nextWeek : '[haftaya] dddd [saat] LT',
lastDay : '[dün] LT',
lastWeek : '[geçen hafta] dddd [saat] LT',
sameElse : 'L'
},
relativeTime : {
future : "%s sonra",
past : "%s önce",
s : "birkaç saniye",
m : "bir dakika",
mm : "%d dakika",
h : "bir saat",
hh : "%d saat",
d : "bir gün",
dd : "%d gün",
M : "bir ay",
MM : "%d ay",
y : "bir yıl",
yy : "%d yıl"
},
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.
}
});
}));

View File

@@ -0,0 +1,55 @@
// moment.js language configuration
// language : Morocco Central Atlas Tamaziɣt in Latin (tzm-la)
// author : Abdel Said : https://github.com/abdelsaid
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('tzm-la', {
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("_"),
weekdaysShort : "asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),
weekdaysMin : "asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".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: "[asdkh g] LT",
nextDay: '[aska g] LT',
nextWeek: 'dddd [g] LT',
lastDay: '[assant g] LT',
lastWeek: 'dddd [g] LT',
sameElse: 'L'
},
relativeTime : {
future : "dadkh s yan %s",
past : "yan %s",
s : "imik",
m : "minuḍ",
mm : "%d minuḍ",
h : "saɛa",
hh : "%d tassaɛin",
d : "ass",
dd : "%d ossan",
M : "ayowr",
MM : "%d iyyirn",
y : "asgas",
yy : "%d isgasn"
},
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.
}
});
}));

View File

@@ -0,0 +1,55 @@
// moment.js language configuration
// language : Morocco Central Atlas Tamaziɣt (tzm)
// author : Abdel Said : https://github.com/abdelsaid
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('tzm', {
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"
},
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 oⵙⵙⴰ",
M : "ⴰⵢoⵓ",
MM : "%d ⵉⵢⵢⵉⵔⵏ",
y : "ⴰⵙⴳⴰⵙ",
yy : "%d ⵉⵙⴳⴰⵙⵏ"
},
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.
}
});
}));

View File

@@ -0,0 +1,157 @@
// moment.js language configuration
// language : ukrainian (uk)
// author : zemlanin : https://github.com/zemlanin
// Author : Menelion Elensúle : https://github.com/Oire
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
function plural(word, num) {
var forms = word.split('_');
return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
}
function relativeTimeWithPlural(number, withoutSuffix, key) {
var format = {
'mm': 'хвилина_хвилини_хвилин',
'hh': 'година_години_годин',
'dd': ень_дні_днів',
'MM': ісяць_місяціісяців',
'yy': 'рік_роки_років'
};
if (key === 'm') {
return withoutSuffix ? 'хвилина' : 'хвилину';
}
else if (key === 'h') {
return withoutSuffix ? 'година' : 'годину';
}
else {
return number + ' ' + plural(format[key], +number);
}
}
function monthsCaseReplace(m, format) {
var months = {
'nominative': 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_'),
'accusative': 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_')
},
nounCase = (/D[oD]? *MMMM?/).test(format) ?
'accusative' :
'nominative';
return months[nounCase][m.month()];
}
function weekdaysCaseReplace(m, format) {
var weekdays = {
'nominative': еділя_понеділок_вівторок_середаетвер_пятниця_субота'.split('_'),
'accusative': еділю_понеділок_вівторок_середуетвер_пятницю_суботу'.split('_'),
'genitive': еділі_понеділкаівторка_середи_четверга_пятниці_суботи'.split('_')
},
nounCase = (/(\[[ВвУу]\]) ?dddd/).test(format) ?
'accusative' :
((/\[?(?:минулої|наступної)? ?\] ?dddd/).test(format) ?
'genitive' :
'nominative');
return weekdays[nounCase][m.day()];
}
function processHoursFunction(str) {
return function () {
return str + 'о' + (this.hours() === 11 ? 'б' : '') + '] LT';
};
}
moment.lang('uk', {
months : monthsCaseReplace,
monthsShort : "січ_лют_бер_квіт_трав_черв_лип_серп_веровт_лист_груд".split("_"),
weekdays : weekdaysCaseReplace,
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"
},
calendar : {
sameDay: processHoursFunction('[Сьогодні '),
nextDay: processHoursFunction('[Завтра '),
lastDay: processHoursFunction('[Вчора '),
nextWeek: processHoursFunction('[У] dddd ['),
lastWeek: function () {
switch (this.day()) {
case 0:
case 3:
case 5:
case 6:
return processHoursFunction('[Минулої] dddd [').call(this);
case 1:
case 2:
case 4:
return processHoursFunction('[Минулого] dddd [').call(this);
}
},
sameElse: 'L'
},
relativeTime : {
future : "за %s",
past : "%s тому",
s : "декілька секунд",
m : relativeTimeWithPlural,
mm : relativeTimeWithPlural,
h : "годину",
hh : relativeTimeWithPlural,
d : "день",
dd : relativeTimeWithPlural,
M : "місяць",
MM : relativeTimeWithPlural,
y : "рік",
yy : relativeTimeWithPlural
},
// M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return "ночі";
} else if (hour < 12) {
return "ранку";
} else if (hour < 17) {
return "дня";
} else {
return "вечора";
}
},
ordinal: function (number, period) {
switch (period) {
case 'M':
case 'd':
case 'DDD':
case 'w':
case 'W':
return number + '-й';
case 'D':
return number + '-го';
default:
return number;
}
},
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.
}
});
}));

View File

@@ -0,0 +1,52 @@
// moment.js language configuration
// language : vietnamese (vn)
// author : Bang Nguyen : https://github.com/bangnk
require('../moment').lang('vn', {
months : "tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12".split("_"),
monthsShort : "Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12".split("_"),
weekdays : "chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy".split("_"),
weekdaysShort : "CN_T2_T3_T4_T5_T6_T7".split("_"),
weekdaysMin : "CN_T2_T3_T4_T5_T6_T7".split("_"),
longDateFormat : {
LT : "HH:mm",
L : "DD/MM/YYYY",
LL : "D MMMM [năm] YYYY",
LLL : "D MMMM [năm] YYYY LT",
LLLL : "dddd, D MMMM [năm] YYYY LT",
l : "DD/M/YYYY",
ll : "D MMM YYYY",
lll : "D MMM YYYY LT",
llll : "ddd, D MMM YYYY LT"
},
calendar : {
sameDay: "[Hôm nay lúc] LT",
nextDay: '[Ngày mai lúc] LT',
nextWeek: 'dddd [tuần tới lúc] LT',
lastDay: '[Hôm qua lúc] LT',
lastWeek: 'dddd [tuần rồi lúc] LT',
sameElse: 'L'
},
relativeTime : {
future : "%s tới",
past : "%s trước",
s : "vài giây",
m : "một phút",
mm : "%d phút",
h : "một giờ",
hh : "%d giờ",
d : "một ngày",
dd : "%d ngày",
M : "một tháng",
MM : "%d tháng",
y : "một năm",
yy : "%d năm"
},
ordinal : function (number) {
return number;
},
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.
}
});

View File

@@ -0,0 +1,84 @@
// moment.js language configuration
// language : chinese
// author : suupic : https://github.com/suupic
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('zh-cn', {
months : "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),
monthsShort : "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
weekdays : "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),
weekdaysShort : "周日_周一_周二_周三_周四_周五_周六".split("_"),
weekdaysMin : "日_一_二_三_四_五_六".split("_"),
longDateFormat : {
LT : "Ah点mm",
L : "YYYY年MMMD日",
LL : "YYYY年MMMD日",
LLL : "YYYY年MMMD日LT",
LLLL : "YYYY年MMMD日ddddLT",
l : "YYYY年MMMD日",
ll : "YYYY年MMMD日",
lll : "YYYY年MMMD日LT",
llll : "YYYY年MMMD日ddddLT"
},
meridiem : function (hour, minute, isLower) {
var hm = hour * 100 + minute;
if (hm < 900) {
return "早上";
} else if (hm < 1130) {
return "上午";
} else if (hm < 1230) {
return "中午";
} else if (hm < 1800) {
return "下午";
} else {
return "晚上";
}
},
calendar : {
sameDay : '[今天]LT',
nextDay : '[明天]LT',
nextWeek : '[下]ddddLT',
lastDay : '[昨天]LT',
lastWeek : '[上]ddddLT',
sameElse : 'L'
},
ordinal : function (number, period) {
switch (period) {
case "d" :
case "D" :
case "DDD" :
return number + "日";
case "M" :
return number + "月";
case "w" :
case "W" :
return number + "周";
default :
return number;
}
},
relativeTime : {
future : "%s内",
past : "%s前",
s : "几秒",
m : "1分钟",
mm : "%d分钟",
h : "1小时",
hh : "%d小时",
d : "1天",
dd : "%d天",
M : "1个月",
MM : "%d个月",
y : "1年",
yy : "%d年"
}
});
}));

View File

@@ -0,0 +1,84 @@
// moment.js language configuration
// language : traditional chinese (zh-tw)
// author : Ben : https://github.com/ben-lin
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
moment.lang('zh-tw', {
months : "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),
monthsShort : "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
weekdays : "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),
weekdaysShort : "週日_週一_週二_週三_週四_週五_週六".split("_"),
weekdaysMin : "日_一_二_三_四_五_六".split("_"),
longDateFormat : {
LT : "Ah點mm",
L : "YYYY年MMMD日",
LL : "YYYY年MMMD日",
LLL : "YYYY年MMMD日LT",
LLLL : "YYYY年MMMD日ddddLT",
l : "YYYY年MMMD日",
ll : "YYYY年MMMD日",
lll : "YYYY年MMMD日LT",
llll : "YYYY年MMMD日ddddLT"
},
meridiem : function (hour, minute, isLower) {
var hm = hour * 100 + minute;
if (hm < 900) {
return "早上";
} else if (hm < 1130) {
return "上午";
} else if (hm < 1230) {
return "中午";
} else if (hm < 1800) {
return "下午";
} else {
return "晚上";
}
},
calendar : {
sameDay : '[今天]LT',
nextDay : '[明天]LT',
nextWeek : '[下]ddddLT',
lastDay : '[昨天]LT',
lastWeek : '[上]ddddLT',
sameElse : 'L'
},
ordinal : function (number, period) {
switch (period) {
case "d" :
case "D" :
case "DDD" :
return number + "日";
case "M" :
return number + "月";
case "w" :
case "W" :
return number + "週";
default :
return number;
}
},
relativeTime : {
future : "%s內",
past : "%s前",
s : "幾秒",
m : "一分鐘",
mm : "%d分鐘",
h : "一小時",
hh : "%d小時",
d : "一天",
dd : "%d天",
M : "一個月",
MM : "%d個月",
y : "一年",
yy : "%d年"
}
});
}));

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
var profile = {
resourceTags: {
ignore: function(filename, mid){
// only include moment/moment
return mid != "moment/moment";
},
amd: function(filename, mid){
return /\.js$/.test(filename);
}
}
};

View File

@@ -0,0 +1,56 @@
{
"name": "moment",
"version": "2.2.1",
"description": "Parse, manipulate, and display dates.",
"homepage": "http://momentjs.com",
"author": "Iskren Ivov Chernev <iskren.chernev@gmail.com> (https://github.com/ichernev)",
"contributors": [
"Tim Wood <washwithcare@gmail.com> (http://timwoodcreates.com/)",
"Rocky Meza (http://rockymeza.com)",
"Matt Johnson <mj1856@hotmail.com> (http://codeofmatt.com)",
"Isaac Cambron <isaac@isaaccambron.com> (http://drunkencoder.net/)"
],
"keywords": [
"moment",
"date",
"time",
"parse",
"format",
"validate",
"i18n",
"l10n",
"ender"
],
"main": "./moment.js",
"engines": {
"node": "*"
},
"repository": {
"type": "git",
"url": "https://github.com/moment/moment.git"
},
"bugs": {
"url": "https://github.com/moment/moment/issues"
},
"licenses" : [
{
"type" : "MIT"
}
],
"devDependencies" : {
"uglify-js" : "latest",
"grunt" : "latest",
"nodeunit" : "latest",
"grunt-contrib-jshint" : "latest",
"grunt-contrib-nodeunit" : "latest",
"grunt-contrib-concat" : "latest",
"grunt-contrib-uglify" : "latest",
"grunt-contrib-watch" : "latest",
"grunt-lib-legacyhelpers" : "latest"
},
"scripts": {
"test": "grunt"
},
"ender": "./ender.js",
"dojoBuild": "package.js"
}

View File

@@ -0,0 +1,274 @@
A lightweight javascript date library for parsing, validating, manipulating, and formatting dates.
# [Documentation](http://momentjs.com/docs/)
Upgrading to 2.0.0
==================
There are a number of small backwards incompatible changes with version 2.0.0.
[See them and their descriptions here](https://gist.github.com/timrwood/e72f2eef320ed9e37c51#backwards-incompatible-changes)
Changed language ordinal method to return the number + ordinal instead of just the ordinal.
Changed two digit year parsing cutoff to match strptime.
Removed `moment#sod` and `moment#eod` in favor of `moment#startOf` and `moment#endOf`.
Removed `moment.humanizeDuration()` in favor of `moment.duration().humanize()`.
Removed the lang data objects from the top level namespace.
Duplicate `Date` passed to `moment()` instead of referencing it.
Travis Build Status
===================
Develop [![Build Status](https://travis-ci.org/moment/moment.png?branch=develop)](https://travis-ci.org/moment/moment)
Master [![Build Status](https://travis-ci.org/moment/moment.png?branch=master)](https://travis-ci.org/moment/moment)
Changelog
=========
### 2.2.1
Fixed bug in string prototype test.
Updated authors and contributors.
### 2.2.0 [See changelog](https://gist.github.com/ichernev/00f837a9baf46a3565e4)
Added bower support.
Language files now use UMD.
Creating moment defaults to current date/month/year.
Added a bundle of moment and all language files.
### 2.1.0 [See changelog](https://gist.github.com/timrwood/b8c2d90d528eddb53ab5)
Added better week support.
Added ability to set offset with `moment#zone`.
Added ability to set month or weekday from a string.
Added `moment#min` and `moment#max`
### 2.0.0 [See changelog](https://gist.github.com/timrwood/e72f2eef320ed9e37c51)
Added short form localized tokens.
Added ability to define language a string should be parsed in.
Added support for reversed add/subtract arguments.
Added support for `endOf('week')` and `startOf('week')`.
Fixed the logic for `moment#diff(Moment, 'months')` and `moment#diff(Moment, 'years')`
`moment#diff` now floors instead of rounds.
Normalized `moment#toString`.
Added `isSame`, `isAfter`, and `isBefore` methods.
Added better week support.
Added `moment#toJSON`
Bugfix: Fixed parsing of first century dates
Bugfix: Parsing 10Sep2001 should work as expected
Bugfix: Fixed wierdness with `moment.utc()` parsing.
Changed language ordinal method to return the number + ordinal instead of just the ordinal.
Changed two digit year parsing cutoff to match strptime.
Removed `moment#sod` and `moment#eod` in favor of `moment#startOf` and `moment#endOf`.
Removed `moment.humanizeDuration()` in favor of `moment.duration().humanize()`.
Removed the lang data objects from the top level namespace.
Duplicate `Date` passed to `moment()` instead of referencing it.
### 1.7.2 [See discussion](https://github.com/timrwood/moment/issues/456)
Bugfixes
### 1.7.1 [See discussion](https://github.com/timrwood/moment/issues/384)
Bugfixes
### 1.7.0 [See discussion](https://github.com/timrwood/moment/issues/288)
Added `moment.fn.endOf()` and `moment.fn.startOf()`.
Added validation via `moment.fn.isValid()`.
Made formatting method 3x faster. http://jsperf.com/momentjs-cached-format-functions
Add support for month/weekday callbacks in `moment.fn.format()`
Added instance specific languages.
Added two letter weekday abbreviations with the formatting token `dd`.
Various language updates.
Various bugfixes.
### 1.6.0 [See discussion](https://github.com/timrwood/moment/pull/268)
Added Durations.
Revamped parser to support parsing non-separated strings (YYYYMMDD vs YYYY-MM-DD).
Added support for millisecond parsing and formatting tokens (S SS SSS)
Added a getter for `moment.lang()`
Various bugfixes.
There are a few things deprecated in the 1.6.0 release.
1. The format tokens `z` and `zz` (timezone abbreviations like EST CST MST etc) will no longer be supported. Due to inconsistent browser support, we are unable to consistently produce this value. See [this issue](https://github.com/timrwood/moment/issues/162) for more background.
2. The method `moment.fn.native` is deprecated in favor of `moment.fn.toDate`. There continue to be issues with Google Closure Compiler throwing errors when using `native`, even in valid instances.
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).
### 1.5.0 [See milestone](https://github.com/timrwood/moment/issues?milestone=10&page=1&state=closed)
Added UTC mode.
Added automatic ISO8601 parsing.
Various bugfixes.
### 1.4.0 [See milestone](https://github.com/timrwood/moment/issues?milestone=8&state=closed)
Added `moment.fn.toDate` as a replacement for `moment.fn.native`.
Added `moment.fn.sod` and `moment.fn.eod` to get the start and end of day.
Various bugfixes.
### 1.3.0 [See milestone](https://github.com/timrwood/moment/issues?milestone=7&state=closed)
Added support for parsing month names in the current language.
Added escape blocks for parsing tokens.
Added `moment.fn.calendar` to format strings like 'Today 2:30 PM', 'Tomorrow 1:25 AM', and 'Last Sunday 4:30 AM'.
Added `moment.fn.day` as a setter.
Various bugfixes
### 1.2.0 [See milestone](https://github.com/timrwood/moment/issues?milestone=4&state=closed)
Added timezones to parser and formatter.
Added `moment.fn.isDST`.
Added `moment.fn.zone` to get the timezone offset in minutes.
### 1.1.2 [See milestone](https://github.com/timrwood/moment/issues?milestone=6&state=closed)
Various bugfixes
### 1.1.1 [See milestone](https://github.com/timrwood/moment/issues?milestone=5&state=closed)
Added time specific diffs (months, days, hours, etc)
### 1.1.0
Added `moment.fn.format` localized masks. 'L LL LLL LLLL' [issue 29](https://github.com/timrwood/moment/pull/29)
Fixed [issue 31](https://github.com/timrwood/moment/pull/31).
### 1.0.1
Added `moment.version` to get the current version.
Removed `window !== undefined` when checking if module exists to support browserify. [issue 25](https://github.com/timrwood/moment/pull/25)
### 1.0.0
Added convenience methods for getting and setting date parts.
Added better support for `moment.add()`.
Added better lang support in NodeJS.
Renamed library from underscore.date to Moment.js
### 0.6.1
Added Portuguese, Italian, and French language support
### 0.6.0
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
Bugfix 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
Bugfix for [issue 5](https://github.com/timrwood/underscore.date/pull/5).
### 0.5.0
Dropped the redundant `_date.date()` in favor of `_date()`.
Removed `_date.now()`, as it is a duplicate of `_date()` with no parameters.
Removed `_date.isLeapYear(yearNumber)`. 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
Added date input formats for input strings.
### 0.4.0
Added underscore.date to npm. Removed dependencies on underscore.
### 0.3.2
Added `'z'` and `'zz'` to `_.date().format()`. Cleaned up some redundant code to trim off some bytes.
### 0.3.1
Cleaned up the namespace. Moved all date manipulation and display functions to the _.date() object.
### 0.3.0
Switched to the Underscore methodology of not mucking with the native objects' prototypes.
Made chaining possible.
### 0.2.1
Changed date names to be a more pseudo standardized 'dddd, MMMM Do YYYY, h:mm:ss a'.
Added `Date.prototype` functions `add`, `subtract`, `isdst`, and `isleapyear`.
### 0.2.0
Changed function names to be more concise.
Changed date format from php date format to custom format.
### 0.1.0
Initial release
License
=======
Moment.js is freely distributable under the terms of the MIT license.

View File

@@ -0,0 +1,9 @@
module.exports = function (grunt) {
grunt.registerTask('component', function () {
var config = JSON.parse(grunt.file.read('component.json'));
config.files = grunt.file.expand('lang/*.js');
config.files.unshift('moment.js');
grunt.file.write('component.json', JSON.stringify(config, true, 2));
});
}

View File

@@ -0,0 +1,49 @@
module.exports = function (grunt) {
grunt.registerTask('embed_languages', function () {
var config = grunt.config('embed_languages');
var files = grunt.file.expand(config.targetLangs);
var embeddedContents = determineEmbeddedContent(files);
var momentContents = grunt.file.read(config.moment);
var modifiedContents = momentContents.replace('/* EMBED_LANGUAGES */', function () {
// If we don't do this, $ symbols in lang files may get interpreted in
// the regex replacement
return embeddedContents;
});
grunt.file.write(config.dest, modifiedContents);
});
var languageReset = 'moment.lang(\'en\');';
function determineEmbeddedContent(files) {
var embeddedContent = '';
files.forEach(function (file) {
embeddedContent += transformFile(file);
});
embeddedContent += '\n ' + languageReset + '\n';
return embeddedContent;
}
var reTransform = /function \(factory\) \{[^]*\}(?=\(function \(moment\) \{)/gm;
var replaceWith =
'function (factory) {\n' +
' factory(moment);\n' +
'}';
function transformFile(file) {
var fileContents = grunt.file.read(file);
if (!fileContents.match(reTransform)) {
grunt.warn('Warning: all language files must use the common UMD wrapper pattern. Failed language file: ' + file);
return '';
}
return fileContents.replace(reTransform, replaceWith);
}
};

View File

@@ -0,0 +1,123 @@
var https = require("https"),
zlib = require('zlib'),
path = require('path'),
fs = require('fs');
var count = 0;
var resolved = 0;
var outputs = [];
var done;
function check() {
if (resolved === count) {
normalize();
display();
}
}
function makeBar(length) {
var i = '';
while (i.length < length) {
i += '=';
}
return i;
}
function normalize() {
var i,
max = 0,
max2 = 0;
for (i = 0; i < count; i ++) {
max = Math.max(max, outputs[i].gzip);
max2 = Math.max(max2, outputs[i].original);
}
for (i = 0; i < count; i ++) {
outputs[i].bargraph = makeBar((outputs[i].gzip / max) * 80);
outputs[i].bargraph2 = makeBar((outputs[i].original / max2) * 80);
}
}
function display() {
var i;
for (i = 0; i < count; i ++) {
console.log(outputs[i].version + ' ' + outputs[i].gzip + ' ' + outputs[i].original);
console.log('gzip ' + outputs[i].bargraph);
console.log('orig ' + outputs[i].bargraph2);
}
done();
}
function getSizeAtVersion(version, path) {
var data = '',
op = {},
req = https.request({
host: 'raw.github.com',
port: 443,
path: '/timrwood/moment/' + version + path
}, function (res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
data += chunk;
});
res.on('end', function (e) {
zlib.gzip(data, function (error, result) {
op.version = version;
op.gzip = result.length;
op.original = data.length;
resolved ++;
check();
});
});
});
req.on('error', function (e) {
console.log('problem with request: ' + e.message);
});
req.end();
count++;
outputs.push(op);
}
function getRemote() {
var old_versions = '1.0.1 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.4.0'.split(' '),
new_versions = '1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.7.1'.split(' '),
i;
for (i = 0; i < old_versions.length; i++) {
getSizeAtVersion(old_versions[i], '/moment.min.js');
}
for (i = 0; i < new_versions.length; i++) {
getSizeAtVersion(new_versions[i], '/min/moment.min.js');
}
}
function getLocal() {
count ++;
var op = {};
outputs.push(op);
fs.readFile(path.normalize(__dirname + '/../min/moment.min.js'), 'utf8', function (err, data) {
if (err) {
throw err;
}
zlib.gzip(data, function (error, result) {
op.version = '.next';
op.gzip = result.length;
op.original = data.length;
resolved ++;
check();
});
});
}
module.exports = function (grunt) {
grunt.registerTask('history', 'Check the codebase filesize over different releases.', function () {
done = this.async();
getRemote();
getLocal();
});
};

View File

@@ -0,0 +1,60 @@
var https = require("https"),
zlib = require('zlib'),
path = require('path'),
fs = require('fs');
var stable = '1.7.1',
done;
function getVersion(path, cb) {
var data = '',
req = https.request({
host: 'raw.github.com',
port: 443,
path: '/timrwood/moment/' + path
}, function (res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
data += chunk;
});
res.on('end', function (e) {
zlib.gzip(data, function (error, result) {
cb(data.length, result.length);
});
});
});
req.on('error', function (e) {
console.log('problem with request: ' + e.message);
});
req.end();
}
function printDiffs(stableLen, stableGzip, currentLen, currentGzip) {
var diff = currentLen - stableLen,
gzipDiff = currentGzip - stableGzip;
console.log("Filesize difference from current branch to " + stable);
console.log(stable + " " + stableLen + ' / ' + stableGzip);
console.log("curr " + currentLen + ' / ' + currentGzip);
console.log("diff " + (diff > 0 ? '+' : '') + diff);
console.log("gzip " + (gzipDiff > 0 ? '+' : '') + gzipDiff);
}
module.exports = function (grunt) {
grunt.registerTask('size', 'Check the codebase filesize against the latest stable version.', function () {
done = this.async();
fs.readFile(path.normalize(__dirname + '/../min/moment.min.js'), 'utf8', function (err, data) {
if (err) {
throw err;
}
zlib.gzip(data, function (error, result) {
getVersion(stable + '/min/moment.min.js', function (stableLength, stableGzipLength) {
printDiffs(stableLength, stableGzipLength, data.length, result.length);
done();
});
});
});
});
};

View File

@@ -0,0 +1,60 @@
var fs = require('fs');
module.exports = function (grunt) {
var ZONE_TAB = '/usr/share/zoneinfo/zone.tab';
grunt.registerTask('zones', 'Run the unit tests in different timezones.', function () {
var done = this.async();
getAllTimezones(function (err, zones) {
if (err != null) {
throw err;
}
(function iterator(i) {
if (i >= zones.length) {
return done();
}
runTestsInZone(zones[i], function (err) {
if (err != null) {
throw err;
}
iterator(i+1);
});
}(0));
});
});
function getAllTimezones (callback) {
fs.readFile(ZONE_TAB, 'ascii', function (err, content) {
if (err != null) {
callback(err);
}
callback(null, content.split(/\r\n|\r|\n/)
// remove empty and commented lines
.filter(function (line) { return line && !/^#/.test(line); })
// country code TAB coordinates TAB timezone
.map(function (line) { return line.split('\t')[2]; }));
});
};
function runTestsInZone (zone, next) {
grunt.log.ok("Running tests in zone " + zone);
grunt.util.spawn({
cmd: "grunt",
opts: { env: {
"PATH": process.env.PATH,
"TZ": zone
} },
args: ["--no-color", "nodeunit"]
}, function (err, result, code) {
if (code !== 0) {
grunt.log.error(result.stdout.split(/\r\n|\r|\n/)
.filter(function (line) { return /^(>>|Warning:|$)/.test(line) })
.map(function (line) { return (line.substr(0, 3) === '>> ' ? line.substr(3) : line); })
.join('\n'));
}
next();
});
};
};

View File

@@ -0,0 +1,345 @@
// moment.js Moroccan arabic (ar-ma) tests
// author: Abdel Said : https://github.com/abdelsaid
var moment = require("../../moment");
exports["lang:ar-ma"] = {
setUp : function (cb) {
moment.lang('ar-ma');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'يناير:يناير_فبراير:فبراير_مارس:مارس_أبريل:أبريل_ماي:ماي_يونيو:يونيو_يوليوز:يوليوز_غشت:غشت_شتنبر:شتنبر_أكتوبر:أكتوبر_نونبر:نونبر_دجنبر:دجنبر'.split("_"), 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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد, فبراير 14 2010, 3:25:50 pm'],
['ddd, hA', 'احد, 3PM'],
['M Mo MM MMMM MMM', '2 2 02 فبراير فبراير'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14 14'],
['d do dddd ddd dd', '0 0 الأحد احد ح'],
['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'],
['[the] DDDo [day of the year]', 'the 45 day of the year'],
['L', '14/02/2010'],
['LL', '14 فبراير 2010'],
['LLL', '14 فبراير 2010 15:25'],
['LLLL', 'الأحد 14 فبراير 2010 15:25'],
['l', '14/2/2010'],
['ll', '14 فبراير 2010'],
['lll', '14 فبراير 2010 15:25'],
['llll', 'احد 14 فبراير 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);
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);
var expected = 'يناير يناير_فبراير فبراير_مارس مارس_أبريل أبريل_ماي ماي_يونيو يونيو_يوليوز يوليوز_غشت غشت_شتنبر شتنبر_أكتوبر أكتوبر_نونبر نونبر_دجنبر دجنبر'.split("_"), 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);
var expected = 'الأحد احد ح_الإتنين اتنين ن_الثلاثاء ثلاثاء ث_الأربعاء اربعاء ر_الخميس خميس خ_الجمعة جمعة ج_السبت سبت س'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "ثوان", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "دقيقة", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "دقيقة", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 دقائق", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 دقائق", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "ساعة", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "ساعة", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 ساعات", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 ساعات", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 ساعات", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "يوم", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "يوم", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 أيام", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "يوم", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 أيام", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 أيام", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "شهر", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "شهر", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "شهر", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 أشهر", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 أشهر", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 أشهر", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "شهر", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 أشهر", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 أشهر", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "سنة", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "سنة", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 سنوات", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "سنة", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 سنوات", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "في ثوان", "prefix");
test.equal(moment(0).from(30000), "منذ ثوان", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "منذ ثوان", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "في ثوان", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "في 5 أيام", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "اليوم على الساعة 02:00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "اليوم على الساعة 02:25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "اليوم على الساعة 03:00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "غدا على الساعة 02:00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "اليوم على الساعة 01:00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "أمس على الساعة 02:00", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({d: i});
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Saturday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 31]).week(), 1, "Dec 31 2011 should be week 1");
test.equal(moment([2012, 0, 6]).week(), 1, "Jan 6 2012 should be week 1");
test.equal(moment([2012, 0, 7]).week(), 2, "Jan 7 2012 should be week 2");
test.equal(moment([2012, 0, 13]).week(), 2, "Jan 13 2012 should be week 2");
test.equal(moment([2012, 0, 14]).week(), 3, "Jan 14 2012 should be week 3");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2006, 11, 30]).week(), 1, "Dec 30 2006 should be week 1");
test.equal(moment([2007, 0, 5]).week(), 1, "Jan 5 2007 should be week 1");
test.equal(moment([2007, 0, 6]).week(), 2, "Jan 6 2007 should be week 2");
test.equal(moment([2007, 0, 12]).week(), 2, "Jan 12 2007 should be week 2");
test.equal(moment([2007, 0, 13]).week(), 3, "Jan 13 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 29]).week(), 1, "Dec 29 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 4]).week(), 1, "Jan 4 2008 should be week 1");
test.equal(moment([2008, 0, 5]).week(), 2, "Jan 5 2008 should be week 2");
test.equal(moment([2008, 0, 11]).week(), 2, "Jan 11 2008 should be week 2");
test.equal(moment([2008, 0, 12]).week(), 3, "Jan 12 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 28]).week(), 1, "Dec 28 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 3]).week(), 1, "Jan 3 2003 should be week 1");
test.equal(moment([2003, 0, 4]).week(), 2, "Jan 4 2003 should be week 2");
test.equal(moment([2003, 0, 10]).week(), 2, "Jan 10 2003 should be week 2");
test.equal(moment([2003, 0, 11]).week(), 3, "Jan 11 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 27]).week(), 1, "Dec 27 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 2]).week(), 1, "Jan 2 2009 should be week 1");
test.equal(moment([2009, 0, 3]).week(), 2, "Jan 3 2009 should be week 2");
test.equal(moment([2009, 0, 9]).week(), 2, "Jan 9 2009 should be week 2");
test.equal(moment([2009, 0, 10]).week(), 3, "Jan 10 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(5);
test.equal(moment([2009, 11, 26]).week(), 1, "Dec 26 2009 should be week 1");
test.equal(moment([2010, 0, 1]).week(), 1, "Jan 1 2010 should be week 1");
test.equal(moment([2010, 0, 2]).week(), 2, "Jan 2 2010 should be week 2");
test.equal(moment([2010, 0, 8]).week(), 2, "Jan 8 2010 should be week 2");
test.equal(moment([2010, 0, 9]).week(), 3, "Jan 9 2010 should be week 3");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(5);
test.equal(moment([2011, 0, 1]).week(), 1, "Jan 1 2011 should be week 1");
test.equal(moment([2011, 0, 7]).week(), 1, "Jan 7 2011 should be week 1");
test.equal(moment([2011, 0, 8]).week(), 2, "Jan 8 2011 should be week 2");
test.equal(moment([2011, 0, 14]).week(), 2, "Jan 14 2011 should be week 2");
test.equal(moment([2011, 0, 15]).week(), 3, "Jan 15 2011 should be week 3");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', "Dec 31 2011 should be week 1");
test.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', "Jan 6 2012 should be week 1");
test.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', "Jan 7 2012 should be week 2");
test.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', "Jan 13 2012 should be week 2");
test.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', "Jan 14 2012 should be week 3");
test.done();
}
};

View File

@@ -0,0 +1,349 @@
// moment.js arabic (ar) tests
// author: Abdel Said : https://github.com/abdelsaid
var moment = require("../../moment");
exports["lang:ar"] = {
setUp : function (cb) {
moment.lang('ar');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'يناير/ كانون الثاني:يناير/ كانون الثاني_فبراير/ شباط:فبراير/ شباط_مارس/ آذار:مارس/ آذار_أبريل/ نيسان:أبريل/ نيسان_مايو/ أيار:مايو/ أيار_يونيو/ حزيران:يونيو/ حزيران_يوليو/ تموز:يوليو/ تموز_أغسطس/ آب:أغسطس/ آب_سبتمبر/ أيلول:سبتمبر/ أيلول_أكتوبر/ تشرين الأول:أكتوبر/ تشرين الأول_نوفمبر/ تشرين الثاني:نوفمبر/ تشرين الثاني_ديسمبر/ كانون الأول:ديسمبر/ كانون الأول'.split("_"), i;
function equalTest(input, mmm, i) {
test.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' instead is month ' + moment(input, mmm).month());
}
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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد, فبراير/ شباط 14 2010, 3:25:50 pm'],
['ddd, hA', 'الأحد, 3PM'],
['M Mo MM MMMM MMM', '2 2 02 فبراير/ شباط فبراير/ شباط'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14 14'],
['d do dddd ddd dd', '0 0 الأحد الأحد ح'],
['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'],
['[the] DDDo [day of the year]', 'the 45 day of the year'],
['L', '14/02/2010'],
['LL', '14 فبراير/ شباط 2010'],
['LLL', '14 فبراير/ شباط 2010 15:25'],
['LLLL', 'الأحد 14 فبراير/ شباط 2010 15:25'],
['l', '14/2/2010'],
['ll', '14 فبراير/ شباط 2010'],
['lll', '14 فبراير/ شباط 2010 15:25'],
['llll', 'الأحد 14 فبراير/ شباط 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);
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);
var expected = 'يناير/ كانون الثاني يناير/ كانون الثاني_فبراير/ شباط فبراير/ شباط_مارس/ آذار مارس/ آذار_أبريل/ نيسان أبريل/ نيسان_مايو/ أيار مايو/ أيار_يونيو/ حزيران يونيو/ حزيران_يوليو/ تموز يوليو/ تموز_أغسطس/ آب أغسطس/ آب_سبتمبر/ أيلول سبتمبر/ أيلول_أكتوبر/ تشرين الأول أكتوبر/ تشرين الأول_نوفمبر/ تشرين الثاني نوفمبر/ تشرين الثاني_ديسمبر/ كانون الأول ديسمبر/ كانون الأول'.split("_"), 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);
var expected = 'الأحد الأحد ح_الإثنين الإثنين ن_الثلاثاء الثلاثاء ث_الأربعاء الأربعاء ر_الخميس الخميس خ_الجمعة الجمعة ج_السبت السبت س'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "ثوان", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "دقيقة", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "دقيقة", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 دقائق", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 دقائق", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "ساعة", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "ساعة", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 ساعات", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 ساعات", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 ساعات", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "يوم", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "يوم", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 أيام", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "يوم", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 أيام", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 أيام", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "شهر", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "شهر", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "شهر", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 أشهر", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 أشهر", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 أشهر", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "شهر", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 أشهر", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 أشهر", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "سنة", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "سنة", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 سنوات", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "سنة", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 سنوات", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "في ثوان", "prefix");
test.equal(moment(0).from(30000), "منذ ثوان", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "منذ ثوان", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "في ثوان", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "في 5 أيام", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "اليوم على الساعة 02:00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "اليوم على الساعة 02:25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "اليوم على الساعة 03:00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "غدا على الساعة 02:00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "اليوم على الساعة 01:00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "أمس على الساعة 02:00", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [على الساعة] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Saturday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 31]).week(), 1, "Dec 31 2011 should be week 1");
test.equal(moment([2012, 0, 6]).week(), 1, "Jan 6 2012 should be week 1");
test.equal(moment([2012, 0, 7]).week(), 2, "Jan 7 2012 should be week 2");
test.equal(moment([2012, 0, 13]).week(), 2, "Jan 13 2012 should be week 2");
test.equal(moment([2012, 0, 14]).week(), 3, "Jan 14 2012 should be week 3");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2006, 11, 30]).week(), 1, "Dec 30 2006 should be week 1");
test.equal(moment([2007, 0, 5]).week(), 1, "Jan 5 2007 should be week 1");
test.equal(moment([2007, 0, 6]).week(), 2, "Jan 6 2007 should be week 2");
test.equal(moment([2007, 0, 12]).week(), 2, "Jan 12 2007 should be week 2");
test.equal(moment([2007, 0, 13]).week(), 3, "Jan 13 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 29]).week(), 1, "Dec 29 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 4]).week(), 1, "Jan 4 2008 should be week 1");
test.equal(moment([2008, 0, 5]).week(), 2, "Jan 5 2008 should be week 2");
test.equal(moment([2008, 0, 11]).week(), 2, "Jan 11 2008 should be week 2");
test.equal(moment([2008, 0, 12]).week(), 3, "Jan 12 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 28]).week(), 1, "Dec 28 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 3]).week(), 1, "Jan 3 2003 should be week 1");
test.equal(moment([2003, 0, 4]).week(), 2, "Jan 4 2003 should be week 2");
test.equal(moment([2003, 0, 10]).week(), 2, "Jan 10 2003 should be week 2");
test.equal(moment([2003, 0, 11]).week(), 3, "Jan 11 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 27]).week(), 1, "Dec 27 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 2]).week(), 1, "Jan 2 2009 should be week 1");
test.equal(moment([2009, 0, 3]).week(), 2, "Jan 3 2009 should be week 2");
test.equal(moment([2009, 0, 9]).week(), 2, "Jan 9 2009 should be week 2");
test.equal(moment([2009, 0, 10]).week(), 3, "Jan 10 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(5);
test.equal(moment([2009, 11, 26]).week(), 1, "Dec 26 2009 should be week 1");
test.equal(moment([2010, 0, 1]).week(), 1, "Jan 1 2010 should be week 1");
test.equal(moment([2010, 0, 2]).week(), 2, "Jan 2 2010 should be week 2");
test.equal(moment([2010, 0, 8]).week(), 2, "Jan 8 2010 should be week 2");
test.equal(moment([2010, 0, 9]).week(), 3, "Jan 9 2010 should be week 3");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(5);
test.equal(moment([2011, 0, 1]).week(), 1, "Jan 1 2011 should be week 1");
test.equal(moment([2011, 0, 7]).week(), 1, "Jan 7 2011 should be week 1");
test.equal(moment([2011, 0, 8]).week(), 2, "Jan 8 2011 should be week 2");
test.equal(moment([2011, 0, 14]).week(), 2, "Jan 14 2011 should be week 2");
test.equal(moment([2011, 0, 15]).week(), 3, "Jan 15 2011 should be week 3");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', "Dec 31 2011 should be week 1");
test.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', "Jan 6 2012 should be week 1");
test.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', "Jan 7 2012 should be week 2");
test.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', "Jan 13 2012 should be week 2");
test.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', "Jan 14 2012 should be week 3");
test.done();
}
};

View File

@@ -0,0 +1,364 @@
var moment = require("../../moment");
/**************************************************
Bulgarian
*************************************************/
exports["lang:bg"] = {
setUp : function (cb) {
moment.lang('bg');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'януари янревруари фев_март мар_април апрай май_юни юни_юли юли_август авг_септември сеп_октомври окт_ноември ноеекември дек'.split("_"), 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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'неделя, февруари 14-ти 2010, 3:25:50 pm'],
['ddd, hA', 'нед, 3PM'],
['M Mo MM MMMM MMM', '2 2-ри 02 февруари фев'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14-ти 14'],
['d do dddd ddd dd', '0 0-ев неделя нед нд'],
['DDD DDDo DDDD', '45 45-ти 045'],
['w wo ww', '7 7-ми 07'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['[the] DDDo [day of the year]', 'the 45-ти day of the year'],
['L', '14.02.2010'],
['LL', '14 февруари 2010'],
['LLL', '14 февруари 2010 3:25'],
['LLLL', 'неделя, 14 февруари 2010 3:25'],
['l', '14.2.2010'],
['ll', '14 фев 2010'],
['lll', '14 фев 2010 3:25'],
['llll', 'нед, 14 фев 2010 3: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);
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);
var expected = 'януари янревруари фев_март мар_април апрай май_юни юни_юли юли_август авг_септември сеп_октомври окт_ноември ноеекември дек'.split("_"), 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);
var expected = 'неделя нед нд_понеделник пон пн_вторник вто вт_сряда сря сретвъртък чет чт_петък пет пт_събота съб сб'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "няколко секунди", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "минута", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "минута", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 минути", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 минути", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "час", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "час", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 часа", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 часа", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 часа", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "ден", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "ден", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 дни", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "ден", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 дни", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 дни", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "месец", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "месец", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "месец", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 месеца", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 месеца", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 месеца", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "месец", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 месеца", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 месеца", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "година", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "година", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 години", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "година", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 години", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "след няколко секунди", "prefix");
test.equal(moment(0).from(30000), "преди няколко секунди", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "преди няколко секунди", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "след няколко секунди", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "след 5 дни", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "Днес в 2:00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Днес в 2:25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Днес в 3:00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "Утре в 2:00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "Днес в 1:00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "Вчера в 2:00", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [в] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [в] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [в] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
function makeFormat(d) {
switch (d.day()) {
case 0:
case 3:
case 6:
return '[В изминалата] dddd [в] LT';
case 1:
case 2:
case 4:
case 5:
return '[В изминалия] dddd [в] LT';
}
}
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format(makeFormat(m)), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format(makeFormat(m)), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format(makeFormat(m)), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Monday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 26]).week(), 1, "Dec 26 2011 should be week 1");
test.equal(moment([2012, 0, 1]).week(), 1, "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 2]).week(), 2, "Jan 2 2012 should be week 2");
test.equal(moment([2012, 0, 8]).week(), 2, "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 9]).week(), 3, "Jan 9 2012 should be week 3");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 12]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 1, "Dec 28 2009 should be week 1");
test.equal(moment([2010, 0, 1]).week(), 1, "Jan 1 2010 should be week 1");
test.equal(moment([2010, 0, 3]).week(), 1, "Jan 3 2010 should be week 1");
test.equal(moment([2010, 0, 4]).week(), 2, "Jan 4 2010 should be week 2");
test.equal(moment([2010, 0, 10]).week(), 2, "Jan 10 2010 should be week 2");
test.equal(moment([2010, 0, 11]).week(), 3, "Jan 11 2010 should be week 3");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 1, "Dec 27 2010 should be week 1");
test.equal(moment([2011, 0, 1]).week(), 1, "Jan 1 2011 should be week 1");
test.equal(moment([2011, 0, 2]).week(), 1, "Jan 2 2011 should be week 1");
test.equal(moment([2011, 0, 3]).week(), 2, "Jan 3 2011 should be week 2");
test.equal(moment([2011, 0, 9]).week(), 2, "Jan 9 2011 should be week 2");
test.equal(moment([2011, 0, 10]).week(), 3, "Jan 10 2011 should be week 3");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ви', "Dec 26 2011 should be week 1");
test.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ви', "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-ри', "Jan 2 2012 should be week 2");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-ри', "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-ти', "Jan 9 2012 should be week 3");
test.done();
}
};

View File

@@ -0,0 +1,271 @@
var moment = require("../../moment");
/**************************************************
Breton
*************************************************/
exports["lang:br"] = {
setUp : function (cb) {
moment.lang('br');
cb();
},
tearDown : function (cb) {
moment.lang('br');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = "Genver Gen_C'hwevrer C'hwe_Meurzh Meu_Ebrel Ebr_Mae Mae_Mezheven Eve_Gouere Gou_Eost Eos_Gwengolo Gwe_Here Her_Du Du_Kerzu Ker".split("_"), 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(17);
moment.lang('br');
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', "Sul, C'hwevrer 14vet 2010, 3:25:50 pm"],
['ddd, h A', 'Sul, 3 PM'],
['M Mo MM MMMM MMM', "2 2vet 02 C'hwevrer C'hwe"],
['YYYY YY', '2010 10'],
['D Do DD', '14 14vet 14'],
['d do dddd ddd dd', '0 0vet Sul Sul Su'],
['DDD DDDo DDDD', '45 45vet 045'],
['w wo ww', '6 6vet 06'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['DDDo [devezh] [ar] [vloaz]', '45vet devezh ar vloaz'],
['L', '14/02/2010'],
['LL', "14 a viz C'hwevrer 2010"],
['LLL', "14 a viz C'hwevrer 2010 3e25 PM"],
['LLLL', "Sul, 14 a viz C'hwevrer 2010 3e25 PM"]
],
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('br');
test.equal(moment([2011, 0, 1]).format('DDDo'), '1añ', '1añ');
test.equal(moment([2011, 0, 2]).format('DDDo'), '2vet', '2vet');
test.equal(moment([2011, 0, 3]).format('DDDo'), '3vet', '3vet');
test.equal(moment([2011, 0, 4]).format('DDDo'), '4vet', '4vet');
test.equal(moment([2011, 0, 5]).format('DDDo'), '5vet', '5vet');
test.equal(moment([2011, 0, 6]).format('DDDo'), '6vet', '6vet');
test.equal(moment([2011, 0, 7]).format('DDDo'), '7vet', '7vet');
test.equal(moment([2011, 0, 8]).format('DDDo'), '8vet', '8vet');
test.equal(moment([2011, 0, 9]).format('DDDo'), '9vet', '9vet');
test.equal(moment([2011, 0, 10]).format('DDDo'), '10vet', '10vet');
test.equal(moment([2011, 0, 11]).format('DDDo'), '11vet', '11vet');
test.equal(moment([2011, 0, 12]).format('DDDo'), '12vet', '12vet');
test.equal(moment([2011, 0, 13]).format('DDDo'), '13vet', '13vet');
test.equal(moment([2011, 0, 14]).format('DDDo'), '14vet', '14vet');
test.equal(moment([2011, 0, 15]).format('DDDo'), '15vet', '15vet');
test.equal(moment([2011, 0, 16]).format('DDDo'), '16vet', '16vet');
test.equal(moment([2011, 0, 17]).format('DDDo'), '17vet', '17vet');
test.equal(moment([2011, 0, 18]).format('DDDo'), '18vet', '18vet');
test.equal(moment([2011, 0, 19]).format('DDDo'), '19vet', '19vet');
test.equal(moment([2011, 0, 20]).format('DDDo'), '20vet', '20vet');
test.equal(moment([2011, 0, 21]).format('DDDo'), '21vet', '21vet');
test.equal(moment([2011, 0, 22]).format('DDDo'), '22vet', '22vet');
test.equal(moment([2011, 0, 23]).format('DDDo'), '23vet', '23vet');
test.equal(moment([2011, 0, 24]).format('DDDo'), '24vet', '24vet');
test.equal(moment([2011, 0, 25]).format('DDDo'), '25vet', '25vet');
test.equal(moment([2011, 0, 26]).format('DDDo'), '26vet', '26vet');
test.equal(moment([2011, 0, 27]).format('DDDo'), '27vet', '27vet');
test.equal(moment([2011, 0, 28]).format('DDDo'), '28vet', '28vet');
test.equal(moment([2011, 0, 29]).format('DDDo'), '29vet', '29vet');
test.equal(moment([2011, 0, 30]).format('DDDo'), '30vet', '30vet');
test.equal(moment([2011, 0, 31]).format('DDDo'), '31vet', '31vet');
test.done();
},
"format month" : function (test) {
test.expect(12);
moment.lang('br');
var expected = "Genver Gen_C'hwevrer C'hwe_Meurzh Meu_Ebrel Ebr_Mae Mae_Mezheven Eve_Gouere Gou_Eost Eos_Gwengolo Gwe_Here Her_Du Du_Kerzu Ker".split("_"), 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('br');
var expected = "Sul Sul Su_Lun Lun Lu_Meurzh Meu Me_Merc'her Mer Mer_Yaou Yao Ya_Gwener Gwe Gw_Sadorn Sad Sa".split("_"), 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('br');
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "un nebeud segondennoù", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "ur vunutenn", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "ur vunutenn", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 vunutenn", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 munutenn", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "un eur", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "un eur", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 eur", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 eur", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 eur", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "un devezh", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "un devezh", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 zevezh", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "un devezh", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 devezh", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 devezh", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "ur miz", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "ur miz", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "ur miz", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 viz", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 viz", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 miz", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "ur miz", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 miz", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 miz", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "ur bloaz", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "ur bloaz", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 vloaz", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "ur bloaz", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 bloaz", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
moment.lang('br');
test.equal(moment(30000).from(0), "a-benn un nebeud segondennoù", "prefix");
test.equal(moment(0).from(30000), "un nebeud segondennoù 'zo", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
moment.lang('br');
test.equal(moment().fromNow(), "un nebeud segondennoù 'zo", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
moment.lang('br');
test.equal(moment().add({s: 30}).fromNow(), "a-benn un nebeud segondennoù", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "a-benn 5 devezh", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
moment.lang('br');
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "Hiziv da 2e00 AM", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Hiziv da 2e25 AM", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Hiziv da 3e00 AM", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "Warc'hoazh da 2e00 AM", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "Hiziv da 1e00 AM", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "Dec'h da 2e00 AM", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
moment.lang('br');
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [da] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [da] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [da] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
moment.lang('br');
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('dddd [paset da] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [paset da] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [paset da] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
moment.lang('br');
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
"special mutations for years": function (test) {
test.expect(12);
moment.lang('br');
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "ur bloaz", "mutation 1 year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 2}), true), "2 vloaz", "mutation 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 3}), true), "3 bloaz", "mutation 3 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 4}), true), "4 bloaz", "mutation 4 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 bloaz", "mutation 5 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 9}), true), "9 bloaz", "mutation 9 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 10}), true), "10 vloaz", "mutation 10 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 21}), true), "21 bloaz", "mutation 21 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 22}), true), "22 vloaz", "mutation 22 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 133}), true), "133 bloaz", "mutation 133 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 148}), true), "148 vloaz", "mutation 148 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 261}), true), "261 bloaz", "mutation 261 years");
test.done();
}
};

View File

@@ -0,0 +1,318 @@
var moment = require("../../moment");
/**************************************************
Català
*************************************************/
exports["lang:ca"] = {
setUp : function (cb) {
moment.lang('ca');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = "Gener Gen._Febrer Febr._Març Mar._Abril Abr._Maig Mai._Juny Jun._Juliol Jul._Agost Ag._Setembre Set._Octubre Oct._Novembre Nov._Desembre Des.".split("_"), 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 ordinal" : function (test) {
test.expect(31);
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);
var expected = "Gener Gen._Febrer Febr._Març Mar._Abril Abr._Maig Mai._Juny Jun._Juliol Jul._Agost Ag._Setembre Set._Octubre Oct._Novembre Nov._Desembre Des.".split("_"), 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);
var expected = "Diumenge Dg. Dg_Dilluns Dl. Dl_Dimarts Dt. Dt_Dimecres Dc. Dc_Dijous Dj. Dj_Divendres Dv. Dv_Dissabte Ds. Ds".split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "uns segons", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "un minut", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "un minut", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minuts", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minuts", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "una hora", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "una hora", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 hores", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 hores", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 hores", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "un dia", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "un dia", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 dies", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "un dia", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 dies", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 dies", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "un mes", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "un mes", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "un mes", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 mesos", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 mesos", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 mesos", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "un mes", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 mesos", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 mesos", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "un any", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "un any", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 anys", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "un any", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 anys", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "en uns segons", "prefix");
test.equal(moment(0).from(30000), "fa uns segons", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "fa uns segons", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "en uns segons", "en uns segons");
test.equal(moment().add({d: 5}).fromNow(), "en 5 dies", "en 5 dies");
test.done();
},
"calendar day" : function (test) {
test.expect(7);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "avui a les 2:00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "avui a les 2:25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "avui a les 3:00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "demà a les 2:00", "tomorrow at the same time");
test.equal(moment(a).add({ d: 1, h : -1 }).calendar(), "demà a la 1:00", "tomorrow minus 1 hour");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "avui a la 1:00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "ahir a les 2:00", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[el] dddd [passat a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[el] dddd [passat a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[el] dddd [passat a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Monday is the first day of the week.
// The week that contains Jan 4th is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 52, "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).week(), 1, "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 1, "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).week(), 2, "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 2, "Jan 15 2012 should be week 2");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 13]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 53, "Dec 28 2009 should be week 53");
test.equal(moment([2010, 0, 1]).week(), 53, "Jan 1 2010 should be week 53");
test.equal(moment([2010, 0, 3]).week(), 53, "Jan 3 2010 should be week 53");
test.equal(moment([2010, 0, 4]).week(), 1, "Jan 4 2010 should be week 1");
test.equal(moment([2010, 0, 10]).week(), 1, "Jan 10 2010 should be week 1");
test.equal(moment([2010, 0, 11]).week(), 2, "Jan 11 2010 should be week 2");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 52, "Dec 27 2010 should be week 52");
test.equal(moment([2011, 0, 1]).week(), 52, "Jan 1 2011 should be week 52");
test.equal(moment([2011, 0, 2]).week(), 52, "Jan 2 2011 should be week 52");
test.equal(moment([2011, 0, 3]).week(), 1, "Jan 3 2011 should be week 1");
test.equal(moment([2011, 0, 9]).week(), 1, "Jan 9 2011 should be week 1");
test.equal(moment([2011, 0, 10]).week(), 2, "Jan 10 2011 should be week 2");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1º', "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', "Jan 15 2012 should be week 2");
test.done();
}
};

View File

@@ -0,0 +1,441 @@
var moment = require("../../moment");
/**************************************************
Czech
*************************************************/
exports["lang:cs"] = {
setUp : function (cb) {
moment.lang('cs');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'leden led_únor úno_březen bře_duben dub_květen kvě_červen čvn_červenec čvc_srpen srp_září zář_říjen říj_listopad lis_prosinec pro'.split("_"), i;
function equalTest(input, mmm, monthIndex) {
test.equal(moment(input, mmm).month(), monthIndex, input + ' should be month ' + (monthIndex + 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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss', 'neděle, únor 14. 2010, 3:25:50'],
['ddd, h', 'ne, 3'],
['M Mo MM MMMM MMM', '2 2. 02 únor úno'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14. 14'],
['d do dddd ddd dd', '0 0. neděle ne ne'],
['DDD DDDo DDDD', '45 45. 045'],
['w wo ww', '6 6. 06'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['DDDo [den v roce]', '45. den v roce'],
['L', '14.02.2010'],
['LL', '14. únor 2010'],
['LLL', '14. únor 2010 15:25'],
['LLLL', 'neděle 14. únor 2010 15:25'],
['l', '14.2.2010'],
['ll', '14. úno 2010'],
['lll', '14. úno 2010 15:25'],
['llll', 'ne 14. úno 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);
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);
var expected = 'leden led_únor úno_březen bře_duben dub_květen kvě_červen čvn_červenec čvc_srpen srp_září zář_říjen říj_listopad lis_prosinec pro'.split("_"), 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);
var expected = 'neděle ne ne_pondělí po po_úterý út út_středa st st_čtvrtek čt čt_pátek pá pá_sobota so so'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "pár vteřin", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "minuta", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "minuta", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minuty", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minut", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "hodina", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "hodina", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 hodiny", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 hodin", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 hodin", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "den", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "den", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 dny", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "den", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 dní", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 dní", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "měsíc", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "měsíc", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "měsíc", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 měsíce", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 měsíce", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 měsíce", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "měsíc", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 měsíců", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 měsíců", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "rok", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "rok", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 roky", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "rok", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 let", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "za pár vteřin", "prefix");
test.equal(moment(0).from(30000), "před pár vteřinami", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "před pár vteřinami", "now from now should display as in the past");
test.done();
},
"fromNow (future)" : function (test) {
test.expect(16);
test.equal(moment().add({s: 30}).fromNow(), "za pár vteřin", "in a few seconds");
test.equal(moment().add({m: 1}).fromNow(), "za minutu", "in a minute");
test.equal(moment().add({m: 3}).fromNow(), "za 3 minuty", "in 3 minutes");
test.equal(moment().add({m: 10}).fromNow(), "za 10 minut", "in 10 minutes");
test.equal(moment().add({h: 1}).fromNow(), "za hodinu", "in an hour");
test.equal(moment().add({h: 3}).fromNow(), "za 3 hodiny", "in 3 hours");
test.equal(moment().add({h: 10}).fromNow(), "za 10 hodin", "in 10 hours");
test.equal(moment().add({d: 1}).fromNow(), "za den", "in a day");
test.equal(moment().add({d: 3}).fromNow(), "za 3 dny", "in 3 days");
test.equal(moment().add({d: 10}).fromNow(), "za 10 dní", "in 10 days");
test.equal(moment().add({M: 1}).fromNow(), "za měsíc", "in a month");
test.equal(moment().add({M: 3}).fromNow(), "za 3 měsíce", "in 3 months");
test.equal(moment().add({M: 10}).fromNow(), "za 10 měsíců", "in 10 months");
test.equal(moment().add({y: 1}).fromNow(), "za rok", "in a year");
test.equal(moment().add({y: 3}).fromNow(), "za 3 roky", "in 3 years");
test.equal(moment().add({y: 10}).fromNow(), "za 10 let", "in 10 years");
test.done();
},
"fromNow (past)" : function (test) {
test.expect(16);
test.equal(moment().subtract({s: 30}).fromNow(), "před pár vteřinami", "a few seconds ago");
test.equal(moment().subtract({m: 1}).fromNow(), "před minutou", "a minute ago");
test.equal(moment().subtract({m: 3}).fromNow(), "před 3 minutami", "3 minutes ago");
test.equal(moment().subtract({m: 10}).fromNow(), "před 10 minutami", "10 minutes ago");
test.equal(moment().subtract({h: 1}).fromNow(), "před hodinou", "an hour ago");
test.equal(moment().subtract({h: 3}).fromNow(), "před 3 hodinami", "3 hours ago");
test.equal(moment().subtract({h: 10}).fromNow(), "před 10 hodinami", "10 hours ago");
test.equal(moment().subtract({d: 1}).fromNow(), "před dnem", "a day ago");
test.equal(moment().subtract({d: 3}).fromNow(), "před 3 dny", "3 days ago");
test.equal(moment().subtract({d: 10}).fromNow(), "před 10 dny", "10 days ago");
test.equal(moment().subtract({M: 1}).fromNow(), "před měsícem", "a month ago");
test.equal(moment().subtract({M: 3}).fromNow(), "před 3 měsíci", "3 months ago");
test.equal(moment().subtract({M: 10}).fromNow(), "před 10 měsíci", "10 months ago");
test.equal(moment().subtract({y: 1}).fromNow(), "před rokem", "a year ago");
test.equal(moment().subtract({y: 3}).fromNow(), "před 3 lety", "3 years ago");
test.equal(moment().subtract({y: 10}).fromNow(), "před 10 lety", "10 years ago");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "dnes v 2:00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "dnes v 2:25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "dnes v 3:00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "zítra v 2:00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "dnes v 1:00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "včera v 2:00", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m, nextDay;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
nextDay = '';
switch (m.day()) {
case 0:
nextDay = 'v neděli';
break;
case 1:
nextDay = 'v pondělí';
break;
case 2:
nextDay = 'v úterý';
break;
case 3:
nextDay = 've středu';
break;
case 4:
nextDay = 've čtvrtek';
break;
case 5:
nextDay = 'v pátek';
break;
case 6:
nextDay = 'v sobotu';
break;
}
test.equal(m.calendar(), m.format('[' + nextDay + '] [v] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[' + nextDay + '] [v] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[' + nextDay + '] [v] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m, lastDay;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
lastDay = '';
switch (m.day()) {
case 0:
lastDay = 'minulou neděli';
break;
case 1:
lastDay = 'minulé pondělí';
break;
case 2:
lastDay = 'minulé úterý';
break;
case 3:
lastDay = 'minulou středu';
break;
case 4:
lastDay = 'minulý čtvrtek';
break;
case 5:
lastDay = 'minulý pátek';
break;
case 6:
lastDay = 'minulou sobotu';
break;
}
test.equal(m.calendar(), m.format('[' + lastDay + '] [v] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[' + lastDay + '] [v] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[' + lastDay + '] [v] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
"humanize duration" : function (test) {
test.expect(4);
test.equal(moment.duration(1, "minutes").humanize(), "minuta", "a minute (future)");
test.equal(moment.duration(1, "minutes").humanize(true), "za minutu", "in a minute");
test.equal(moment.duration(-1, "minutes").humanize(), "minuta", "a minute (past)");
test.equal(moment.duration(-1, "minutes").humanize(true), "před minutou", "a minute ago");
test.done();
},
// Monday is the first day of the week.
// The week that contains Jan 4th is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 52, "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).week(), 1, "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 1, "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).week(), 2, "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 2, "Jan 15 2012 should be week 2");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 13]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 53, "Dec 28 2009 should be week 53");
test.equal(moment([2010, 0, 1]).week(), 53, "Jan 1 2010 should be week 53");
test.equal(moment([2010, 0, 3]).week(), 53, "Jan 3 2010 should be week 53");
test.equal(moment([2010, 0, 4]).week(), 1, "Jan 4 2010 should be week 1");
test.equal(moment([2010, 0, 10]).week(), 1, "Jan 10 2010 should be week 1");
test.equal(moment([2010, 0, 11]).week(), 2, "Jan 11 2010 should be week 2");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 52, "Dec 27 2010 should be week 52");
test.equal(moment([2011, 0, 1]).week(), 52, "Jan 1 2011 should be week 52");
test.equal(moment([2011, 0, 2]).week(), 52, "Jan 2 2011 should be week 52");
test.equal(moment([2011, 0, 3]).week(), 1, "Jan 3 2011 should be week 1");
test.equal(moment([2011, 0, 9]).week(), 1, "Jan 9 2011 should be week 1");
test.equal(moment([2011, 0, 10]).week(), 2, "Jan 10 2011 should be week 2");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', "Jan 15 2012 should be week 2");
test.done();
}
};

View File

@@ -0,0 +1,357 @@
var moment = require("../../moment");
/**************************************************
Chuvash
*************************************************/
exports["lang:cv"] = {
setUp : function (cb) {
moment.lang('cv');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'кăрлач кăрарăс нар_пуш пуш_ака акаай май_çĕртме çĕр_утă утă_çурла çур_авăн ав_юпа юпа_чӳк чӳк_раштав раш'.split("_"), 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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'вырсарникун, нарăс 14-мĕш 2010, 3:25:50 pm'],
['ddd, hA', 'выр, 3PM'],
['M Mo MM MMMM MMM', '2 2-мĕш 02 нарăс нар'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14-мĕш 14'],
['d do dddd ddd dd', '0 0-мĕш вырсарникун выр вр'],
['DDD DDDo DDDD', '45 45-мĕш 045'],
['w wo ww', '7 7-мĕш 07'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['Çулăн DDDo кунĕ', 'Çулăн 45-мĕш кунĕ'],
['L', '14-02-2010'],
['LL', '2010 çулхи нарăс уйăхĕн 14-мĕшĕ'],
['LLL', '2010 çулхи нарăс уйăхĕн 14-мĕшĕ, 15:25'],
['LLLL', 'вырсарникун, 2010 çулхи нарăс уйăхĕн 14-мĕшĕ, 15:25'],
['l', '14-2-2010'],
['ll', '2010 çулхи нар уйăхĕн 14-мĕшĕ'],
['lll', '2010 çулхи нар уйăхĕн 14-мĕшĕ, 15:25'],
['llll', 'выр, 2010 çулхи нар уйăхĕн 14-мĕшĕ, 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);
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);
var expected = 'кăрлач кăрарăс нар_пуш пуш_ака акаай май_çĕртме çĕр_утă утă_çурла çур_авăн ав_юпа юпа_чӳк чӳк_раштав раш'.split("_"), 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);
var expected = 'вырсарникун выр врунтикун тун тн_ытларикун ытл ыт_юнкун юн юн_кĕçнерникун кĕç кç_эрнекун эрн эр_шăматкун шăм шм'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "пĕр-ик çеккунт", "44 sekunder = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "пĕр минут", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "пĕр минут", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 минут", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 минут", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "пĕр сехет", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "пĕр сехет", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 сехет", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 сехет", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 сехет", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "пĕр кун", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "пĕр кун", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 кун", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "пĕр кун", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 кун", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 кун", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "пĕр уйăх", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "пĕр уйăх", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "пĕр уйăх", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 уйăх", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 уйăх", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 уйăх", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "пĕр уйăх", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 уйăх", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 уйăх", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "пĕр çул", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "пĕр çул", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 çул", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "пĕр çул", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 çул", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "пĕр-ик çеккунтран", "prefix");
test.equal(moment(0).from(30000), "пĕр-ик çеккунт каялла", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "пĕр-ик çеккунт каялла", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(4);
test.equal(moment().add({s: 30}).fromNow(), "пĕр-ик çеккунтран", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "5 кунран", "in 5 days");
test.equal(moment().add({h: 2}).fromNow(), "2 сехетрен", "in 2 hours, the right suffix!");
test.equal(moment().add({y: 3}).fromNow(), "3 çултан", "in 3 years, the right suffix!");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "Паян 02:00 сехетре", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Паян 02:25 сехетре", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Паян 03:00 сехетре", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "Ыран 02:00 сехетре", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "Паян 01:00 сехетре", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "Ĕнер 02:00 сехетре", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('[Çитес] dddd LT [сехетре]'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[Çитес] dddd LT [сехетре]'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[Çитес] dddd LT [сехетре]'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[Иртнĕ] dddd LT [сехетре]'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[Иртнĕ] dddd LT [сехетре]'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[Иртнĕ] dddd LT [сехетре]'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Monday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 26]).week(), 1, "Dec 26 2011 should be week 1");
test.equal(moment([2012, 0, 1]).week(), 1, "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 2]).week(), 2, "Jan 2 2012 should be week 2");
test.equal(moment([2012, 0, 8]).week(), 2, "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 9]).week(), 3, "Jan 9 2012 should be week 3");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 12]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 1, "Dec 28 2009 should be week 1");
test.equal(moment([2010, 0, 1]).week(), 1, "Jan 1 2010 should be week 1");
test.equal(moment([2010, 0, 3]).week(), 1, "Jan 3 2010 should be week 1");
test.equal(moment([2010, 0, 4]).week(), 2, "Jan 4 2010 should be week 2");
test.equal(moment([2010, 0, 10]).week(), 2, "Jan 10 2010 should be week 2");
test.equal(moment([2010, 0, 11]).week(), 3, "Jan 11 2010 should be week 3");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 1, "Dec 27 2010 should be week 1");
test.equal(moment([2011, 0, 1]).week(), 1, "Jan 1 2011 should be week 1");
test.equal(moment([2011, 0, 2]).week(), 1, "Jan 2 2011 should be week 1");
test.equal(moment([2011, 0, 3]).week(), 2, "Jan 3 2011 should be week 2");
test.equal(moment([2011, 0, 9]).week(), 2, "Jan 9 2011 should be week 2");
test.equal(moment([2011, 0, 10]).week(), 3, "Jan 10 2011 should be week 3");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-мĕш', "Dec 26 2011 should be week 1");
test.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-мĕш', "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-мĕш', "Jan 2 2012 should be week 2");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-мĕш', "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-мĕш', "Jan 9 2012 should be week 3");
test.done();
}
};

View File

@@ -0,0 +1,289 @@
var moment = require("../../moment");
/**************************************************
Danish
*************************************************/
exports["lang:da"] = {
setUp : function (cb) {
moment.lang('da');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'januar jan_februar feb_marts mar_april apr_maj maj_juni jun_juli jul_august aug_september sep_oktober okt_november nov_december dec'.split("_"), 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(22);
var a = [
['dddd [den] Do MMMM YYYY, h:mm:ss a', 'søndag den 14. februar 2010, 3:25:50 pm'],
['ddd hA', 'søn 3PM'],
['M Mo MM MMMM MMM', '2 2. 02 februar feb'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14. 14'],
['d do dddd ddd dd', '0 0. søndag søn sø'],
['DDD DDDo DDDD', '45 45. 045'],
['w wo ww', '6 6. 06'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['[den] DDDo [dag på året]', 'den 45. dag på året'],
['L', '14/02/2010'],
['LL', '14 februar 2010'],
['LLL', '14 februar 2010 15:25'],
['LLLL', 'søndag 14. februar, 2010 15:25'],
['l', '14/2/2010'],
['ll', '14 feb 2010'],
['lll', '14 feb 2010 15:25'],
['llll', 'søn 14. feb, 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);
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);
var expected = 'januar jan_februar feb_marts mar_april apr_maj maj_juni jun_juli jul_august aug_september sep_oktober okt_november nov_december dec'.split("_"), 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);
var expected = 'søndag søn sø_mandag man ma_tirsdag tir ti_onsdag ons on_torsdag tor to_fredag fre fr_lørdag lør lø'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "få sekunder", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "et minut", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "et minut", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minutter", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minutter", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "en time", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "en time", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 timer", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 timer", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 timer", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "en dag", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "en dag", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 dage", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "en dag", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 dage", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 dage", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "en måned", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "en måned", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "en måned", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 måneder", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 måneder", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 måneder", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "en måned", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 måneder", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 måneder", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "et år", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "et år", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 år", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "et år", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 år", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "om få sekunder", "prefix");
test.equal(moment(0).from(30000), "få sekunder siden", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "få sekunder siden", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "om få sekunder", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "om 5 dage", "in 5 days");
test.done();
},
// Monday is the first day of the week.
// The week that contains Jan 4th is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 52, "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).week(), 1, "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 1, "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).week(), 2, "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 2, "Jan 15 2012 should be week 2");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 13]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 53, "Dec 28 2009 should be week 53");
test.equal(moment([2010, 0, 1]).week(), 53, "Jan 1 2010 should be week 53");
test.equal(moment([2010, 0, 3]).week(), 53, "Jan 3 2010 should be week 53");
test.equal(moment([2010, 0, 4]).week(), 1, "Jan 4 2010 should be week 1");
test.equal(moment([2010, 0, 10]).week(), 1, "Jan 10 2010 should be week 1");
test.equal(moment([2010, 0, 11]).week(), 2, "Jan 11 2010 should be week 2");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 52, "Dec 27 2010 should be week 52");
test.equal(moment([2011, 0, 1]).week(), 52, "Jan 1 2011 should be week 52");
test.equal(moment([2011, 0, 2]).week(), 52, "Jan 2 2011 should be week 52");
test.equal(moment([2011, 0, 3]).week(), 1, "Jan 3 2011 should be week 1");
test.equal(moment([2011, 0, 9]).week(), 1, "Jan 9 2011 should be week 1");
test.equal(moment([2011, 0, 10]).week(), 2, "Jan 10 2011 should be week 2");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', "Jan 15 2012 should be week 2");
test.done();
}
};

View File

@@ -0,0 +1,350 @@
var moment = require("../../moment");
/**************************************************
German
*************************************************/
exports["lang:de"] = {
setUp : function (cb) {
moment.lang('de');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'Januar Jan._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split("_"), 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(22);
var a = [
['dddd, Do MMMM YYYY, h:mm:ss a', 'Sonntag, 14. Februar 2010, 3:25:50 pm'],
['ddd, hA', 'So., 3PM'],
['M Mo MM MMMM MMM', '2 2. 02 Februar Febr.'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14. 14'],
['d do dddd ddd dd', '0 0. Sonntag So. So'],
['DDD DDDo DDDD', '45 45. 045'],
['w wo ww', '6 6. 06'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['[the] DDDo [day of the year]', 'the 45. day of the year'],
['L', '14.02.2010'],
['LL', '14. Februar 2010'],
['LLL', '14. Februar 2010 15:25 Uhr'],
['LLLL', 'Sonntag, 14. Februar 2010 15:25 Uhr'],
['l', '14.2.2010'],
['ll', '14. Febr. 2010'],
['lll', '14. Febr. 2010 15:25 Uhr'],
['llll', 'So., 14. Febr. 2010 15:25 Uhr']
],
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);
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);
var expected = 'Januar Jan._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split("_"), 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);
var expected = 'Sonntag So. So_Montag Mo. Mo_Dienstag Di. Di_Mittwoch Mi. Mi_Donnerstag Do. Do_Freitag Fr. Fr_Samstag Sa. Sa'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "ein paar Sekunden", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "eine Minute", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "eine Minute", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 Minuten", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 Minuten", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "eine Stunde", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "eine Stunde", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 Stunden", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 Stunden", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 Stunden", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "ein Tag", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "ein Tag", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 Tage", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "ein Tag", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 Tage", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 Tage", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "ein Monat", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "ein Monat", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "ein Monat", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 Monate", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 Monate", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 Monate", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "ein Monat", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 Monate", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 Monate", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "ein Jahr", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "ein Jahr", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 Jahre", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "ein Jahr", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 Jahre", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "in ein paar Sekunden", "prefix");
test.equal(moment(0).from(30000), "vor ein paar Sekunden", "suffix");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "in ein paar Sekunden", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "in 5 Tagen", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "Heute um 2:00 Uhr", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Heute um 2:25 Uhr", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Heute um 3:00 Uhr", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "Morgen um 2:00 Uhr", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "Heute um 1:00 Uhr", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "Gestern um 2:00 Uhr", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [um] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [um] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [um] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[letzten] dddd [um] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[letzten] dddd [um] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[letzten] dddd [um] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Monday is the first day of the week.
// The week that contains Jan 4th is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 52, "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).week(), 1, "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 1, "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).week(), 2, "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 2, "Jan 15 2012 should be week 2");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 13]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 53, "Dec 28 2009 should be week 53");
test.equal(moment([2010, 0, 1]).week(), 53, "Jan 1 2010 should be week 53");
test.equal(moment([2010, 0, 3]).week(), 53, "Jan 3 2010 should be week 53");
test.equal(moment([2010, 0, 4]).week(), 1, "Jan 4 2010 should be week 1");
test.equal(moment([2010, 0, 10]).week(), 1, "Jan 10 2010 should be week 1");
test.equal(moment([2010, 0, 11]).week(), 2, "Jan 11 2010 should be week 2");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 52, "Dec 27 2010 should be week 52");
test.equal(moment([2011, 0, 1]).week(), 52, "Jan 1 2011 should be week 52");
test.equal(moment([2011, 0, 2]).week(), 52, "Jan 2 2011 should be week 52");
test.equal(moment([2011, 0, 3]).week(), 1, "Jan 3 2011 should be week 1");
test.equal(moment([2011, 0, 9]).week(), 1, "Jan 9 2011 should be week 1");
test.equal(moment([2011, 0, 10]).week(), 2, "Jan 10 2011 should be week 2");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', "Jan 15 2012 should be week 2");
test.done();
}
};

View File

@@ -0,0 +1,381 @@
var moment = require("../../moment");
/**************************************************
Modern Greek
*************************************************/
exports["lang:el"] = {
setUp : function (cb) {
moment.lang('el');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var i,
tests = 'Ιανουάριος Ιαν_Φεβρουάριος Φεβ_Μάρτιος Μαρ_Απρίλιος Απρ_Μάιος Μαϊ_Ιούνιος Ιουν_Ιούλιος Ιουλ_Αύγουστος Αυγ_Σεπτέμβριος Σεπ_Οκτώβριος Οκτ_Νοέμβριος Νοε_Δεκέμβριος Δεκ'.split("_");
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(24);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'Κυριακή, Φεβρουάριος 14η 2010, 3:25:50 μμ'],
['dddd, D MMMM YYYY, h:mm:ss a', 'Κυριακή, 14 Φεβρουαρίου 2010, 3:25:50 μμ'],
['ddd, hA', 'Κυρ, 3ΜΜ'],
['dddd, MMMM YYYY', 'Κυριακή, Φεβρουάριος 2010'],
['M Mo MM MMMM MMM', '2 2η 02 Φεβρουάριος Φεβ'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14η 14'],
['d do dddd ddd dd', '0 0η Κυριακή Κυρ Κυ'],
['DDD DDDo DDDD', '45 45η 045'],
['w wo ww', '6 6η 06'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'μμ ΜΜ'],
['[the] DDDo [day of the year]', 'the 45η day of the year'],
['L', '14/02/2010'],
['LL', '14 Φεβρουαρίου 2010'],
['LLL', '14 Φεβρουαρίου 2010 3:25 ΜΜ'],
['LLLL', 'Κυριακή, 14 Φεβρουαρίου 2010 3:25 ΜΜ'],
['l', '14/2/2010'],
['ll', '14 Φεβ 2010'],
['lll', '14 Φεβ 2010 3:25 ΜΜ'],
['llll', 'Κυρ, 14 Φεβ 2010 3: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);
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);
var i,
expected = 'Ιανουάριος Ιαν_Φεβρουάριος Φεβ_Μάρτιος Μαρ_Απρίλιος Απρ_Μάιος Μαϊ_Ιούνιος Ιουν_Ιούλιος Ιουλ_Αύγουστος Αυγ_Σεπτέμβριος Σεπ_Οκτώβριος Οκτ_Νοέμβριος Νοε_Δεκέμβριος Δεκ'.split("_");
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);
var i,
expected = 'Κυριακή Κυρ Κυ_Δευτέρα Δευ Δε_Τρίτη Τρι Τρ_Τετάρτη Τετ Τε_Πέμπτη Πεμ Πε_Παρασκευή Παρ Πα_Σάββατο Σαβ Σα'.split("_");
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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "δευτερόλεπτα", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "ένα λεπτό", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "ένα λεπτό", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 λεπτά", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 λεπτά", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "μία ώρα", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "μία ώρα", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 ώρες", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 ώρες", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 ώρες", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "μία μέρα", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "μία μέρα", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 μέρες", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "μία μέρα", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 μέρες", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 μέρες", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "ένας μήνας", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "ένας μήνας", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "ένας μήνας", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 μήνες", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 μήνες", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 μήνες", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "ένας μήνας", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 μήνες", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 μήνες", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "ένας χρόνος", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "ένας χρόνος", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 χρόνια", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "ένας χρόνος", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 χρόνια", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "σε δευτερόλεπτα", "prefix");
test.equal(moment(0).from(30000), "δευτερόλεπτα πριν", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "δευτερόλεπτα πριν", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "σε δευτερόλεπτα", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "σε 5 μέρες", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "Σήμερα στις 2:00 ΠΜ", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Σήμερα στις 2:25 ΠΜ", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Σήμερα στις 3:00 ΠΜ", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "Αύριο στις 2:00 ΠΜ", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "Σήμερα στη 1:00 ΠΜ", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "Χθες στις 2:00 ΠΜ", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [' + (m.hours() % 12 === 1 ? 'στη' : 'στις') + '] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [στις] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [στις] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[την προηγούμενη] dddd [' + (m.hours() % 12 === 1 ? 'στη' : 'στις') + '] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[την προηγούμενη] dddd [στις] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[την προηγούμενη] dddd [στις] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Monday is the first day of the week.
// The week that contains Jan 4st is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 52, "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 7]).week(), 1, "Jan 7 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 1, "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 14]).week(), 2, "Jan 14 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 2, "Jan 15 2012 should be week 2");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(6);
test.equal(moment([2006, 11, 31]).week(), 52, "Dec 31 2006 should be week 52");
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 6]).week(), 1, "Jan 6 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 13]).week(), 2, "Jan 13 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 30]).week(), 52, "Dec 30 2007 should be week 52");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 5]).week(), 1, "Jan 5 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 12]).week(), 2, "Jan 12 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 29]).week(), 52, "Dec 29 2002 should be week 52");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 4]).week(), 1, "Jan 4 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 11]).week(), 2, "Jan 11 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 28]).week(), 52, "Dec 28 2008 should be week 52");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 3]).week(), 1, "Jan 3 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 10]).week(), 2, "Jan 10 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(7);
test.equal(moment([2009, 11, 27]).week(), 52, "Dec 27 2009 should be week 52");
test.equal(moment([2010, 0, 1]).week(), 53, "Jan 1 2010 should be week 53");
test.equal(moment([2010, 0, 2]).week(), 53, "Jan 2 2010 should be week 53");
test.equal(moment([2010, 0, 3]).week(), 53, "Jan 3 2010 should be week 1");
test.equal(moment([2010, 0, 9]).week(), 1, "Jan 9 2010 should be week 1");
test.equal(moment([2010, 0, 10]).week(), 1, "Jan 10 2010 should be week 1");
test.equal(moment([2010, 0, 11]).week(), 2, "Jan 11 2010 should be week 2");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 26]).week(), 51, "Dec 26 2010 should be week 51");
test.equal(moment([2011, 0, 1]).week(), 52, "Jan 1 2011 should be week 52");
test.equal(moment([2011, 0, 2]).week(), 52, "Jan 2 2011 should be week 52");
test.equal(moment([2011, 0, 8]).week(), 1, "Jan 8 2011 should be week 1");
test.equal(moment([2011, 0, 9]).week(), 1, "Jan 9 2011 should be week 1");
test.equal(moment([2011, 0, 10]).week(), 2, "Jan 10 2011 should be week 2");
test.done();
},
"weeks year starting sunday format" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52η', "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1η', "Jan 7 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1η', "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2η', "Jan 14 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2η', "Jan 15 2012 should be week 2");
test.done();
}
};

View File

@@ -0,0 +1,378 @@
var moment = require("../../moment");
/**************************************************
English (Canadian)
*************************************************/
exports["lang:en-ca"] = {
setUp : function (cb) {
moment.lang('en-ca');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var i,
tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
['ddd, hA', 'Sun, 3PM'],
['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14th 14'],
['d do dddd ddd dd', '0 0th Sunday Sun Su'],
['DDD DDDo DDDD', '45 45th 045'],
['w wo ww', '8 8th 08'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['[the] DDDo [day of the year]', 'the 45th day of the year'],
['L', '2010-02-14'],
['LL', '14 February, 2010'],
['LLL', '14 February, 2010 3:25 PM'],
['LLLL', 'Sunday, 14 February, 2010 3:25 PM'],
['l', '2010-2-14'],
['ll', '14 Feb, 2010'],
['lll', '14 Feb, 2010 3:25 PM'],
['llll', 'Sun, 14 Feb, 2010 3:25 PM']
],
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);
test.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
test.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
test.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
test.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
test.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
test.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
test.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
test.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
test.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
test.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
test.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
test.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
test.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
test.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
test.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
test.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
test.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
test.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
test.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
test.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
test.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
test.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
test.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
test.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
test.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
test.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
test.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
test.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
test.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
test.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
test.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
test.done();
},
"format month" : function (test) {
test.expect(12);
var i,
expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
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);
var i,
expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split("_");
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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "a few seconds", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "a minute", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "a minute", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minutes", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minutes", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "an hour", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "an hour", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 hours", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 hours", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 hours", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "a day", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "a day", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 days", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "a day", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 days", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 days", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "a month", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "a month", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "a month", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 months", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 months", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 months", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "a month", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 months", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 months", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "a year", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "a year", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 years", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "a year", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 years", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "in a few seconds", "prefix");
test.equal(moment(0).from(30000), "a few seconds ago", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "a few seconds ago", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "in a few seconds", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "in 5 days", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "Today at 2:00 AM", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Today at 2:25 AM", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Today at 3:00 AM", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "Tomorrow at 2:00 AM", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "Today at 1:00 AM", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "Yesterday at 2:00 AM", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[Last] dddd [at] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[Last] dddd [at] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[Last] dddd [at] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Sunday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 1, "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 7]).week(), 1, "Jan 7 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 2, "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 14]).week(), 2, "Jan 14 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 3, "Jan 15 2012 should be week 3");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(6);
test.equal(moment([2006, 11, 31]).week(), 1, "Dec 31 2006 should be week 1");
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 6]).week(), 1, "Jan 6 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 2, "Jan 7 2007 should be week 2");
test.equal(moment([2007, 0, 13]).week(), 2, "Jan 13 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 3, "Jan 14 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 29]).week(), 52, "Dec 29 2007 should be week 52");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 5]).week(), 1, "Jan 5 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 2, "Jan 6 2008 should be week 2");
test.equal(moment([2008, 0, 12]).week(), 2, "Jan 12 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 3, "Jan 13 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 29]).week(), 1, "Dec 29 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 4]).week(), 1, "Jan 4 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 2, "Jan 5 2003 should be week 2");
test.equal(moment([2003, 0, 11]).week(), 2, "Jan 11 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 3, "Jan 12 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 28]).week(), 1, "Dec 28 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 3]).week(), 1, "Jan 3 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 2, "Jan 4 2009 should be week 2");
test.equal(moment([2009, 0, 10]).week(), 2, "Jan 10 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 3, "Jan 11 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 27]).week(), 1, "Dec 27 2009 should be week 1");
test.equal(moment([2010, 0, 1]).week(), 1, "Jan 1 2010 should be week 1");
test.equal(moment([2010, 0, 2]).week(), 1, "Jan 2 2010 should be week 1");
test.equal(moment([2010, 0, 3]).week(), 2, "Jan 3 2010 should be week 2");
test.equal(moment([2010, 0, 9]).week(), 2, "Jan 9 2010 should be week 2");
test.equal(moment([2010, 0, 10]).week(), 3, "Jan 10 2010 should be week 3");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(5);
test.equal(moment([2010, 11, 26]).week(), 1, "Dec 26 2010 should be week 1");
test.equal(moment([2011, 0, 1]).week(), 1, "Jan 1 2011 should be week 1");
test.equal(moment([2011, 0, 2]).week(), 2, "Jan 2 2011 should be week 2");
test.equal(moment([2011, 0, 8]).week(), 2, "Jan 8 2011 should be week 2");
test.equal(moment([2011, 0, 9]).week(), 3, "Jan 9 2011 should be week 3");
test.done();
},
"weeks year starting sunday format" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1st', "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1st', "Jan 7 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2nd', "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2nd', "Jan 14 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', "Jan 15 2012 should be week 3");
test.done();
}
};

View File

@@ -0,0 +1,352 @@
var moment = require("../../moment");
/**************************************************
English
*************************************************/
exports["lang:en-gb"] = {
setUp : function (cb) {
moment.lang('en-gb');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_"), 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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
['ddd, hA', 'Sun, 3PM'],
['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14th 14'],
['d do dddd ddd dd', '0 0th Sunday Sun Su'],
['DDD DDDo DDDD', '45 45th 045'],
['w wo ww', '6 6th 06'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['[the] DDDo [day of the year]', 'the 45th day of the year'],
['L', '14/02/2010'],
['LL', '14 February 2010'],
['LLL', '14 February 2010 15:25'],
['LLLL', 'Sunday, 14 February 2010 15:25'],
['l', '14/2/2010'],
['ll', '14 Feb 2010'],
['lll', '14 Feb 2010 15:25'],
['llll', 'Sun, 14 Feb 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);
test.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
test.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
test.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
test.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
test.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
test.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
test.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
test.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
test.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
test.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
test.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
test.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
test.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
test.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
test.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
test.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
test.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
test.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
test.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
test.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
test.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
test.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
test.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
test.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
test.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
test.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
test.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
test.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
test.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
test.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
test.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
test.done();
},
"format month" : function (test) {
test.expect(12);
var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_"), 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);
var expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "a few seconds", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "a minute", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "a minute", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minutes", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minutes", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "an hour", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "an hour", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 hours", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 hours", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 hours", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "a day", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "a day", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 days", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "a day", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 days", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 days", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "a month", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "a month", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "a month", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 months", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 months", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 months", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "a month", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 months", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 months", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "a year", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "a year", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 years", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "a year", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 years", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "in a few seconds", "prefix");
test.equal(moment(0).from(30000), "a few seconds ago", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "a few seconds ago", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "in a few seconds", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "in 5 days", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "Today at 02:00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Today at 02:25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Today at 03:00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "Tomorrow at 02:00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "Today at 01:00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "Yesterday at 02:00", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[Last] dddd [at] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[Last] dddd [at] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[Last] dddd [at] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Monday is the first day of the week.
// The week that contains Jan 4th is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 52, "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).week(), 1, "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 1, "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).week(), 2, "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 2, "Jan 15 2012 should be week 2");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 13]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 53, "Dec 28 2009 should be week 53");
test.equal(moment([2010, 0, 1]).week(), 53, "Jan 1 2010 should be week 53");
test.equal(moment([2010, 0, 3]).week(), 53, "Jan 3 2010 should be week 53");
test.equal(moment([2010, 0, 4]).week(), 1, "Jan 4 2010 should be week 1");
test.equal(moment([2010, 0, 10]).week(), 1, "Jan 10 2010 should be week 1");
test.equal(moment([2010, 0, 11]).week(), 2, "Jan 11 2010 should be week 2");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 52, "Dec 27 2010 should be week 52");
test.equal(moment([2011, 0, 1]).week(), 52, "Jan 1 2011 should be week 52");
test.equal(moment([2011, 0, 2]).week(), 52, "Jan 2 2011 should be week 52");
test.equal(moment([2011, 0, 3]).week(), 1, "Jan 3 2011 should be week 1");
test.equal(moment([2011, 0, 9]).week(), 1, "Jan 9 2011 should be week 1");
test.equal(moment([2011, 0, 10]).week(), 2, "Jan 10 2011 should be week 2");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1st', "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', "Jan 15 2012 should be week 2");
test.done();
}
};

View File

@@ -0,0 +1,379 @@
var moment = require("../../moment");
/**************************************************
English
*************************************************/
exports["lang:en"] = {
setUp : function (cb) {
moment.lang('en');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var i,
tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
['ddd, hA', 'Sun, 3PM'],
['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14th 14'],
['d do dddd ddd dd', '0 0th Sunday Sun Su'],
['DDD DDDo DDDD', '45 45th 045'],
['w wo ww', '8 8th 08'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['[the] DDDo [day of the year]', 'the 45th day of the year'],
['L', '02/14/2010'],
['LL', 'February 14 2010'],
['LLL', 'February 14 2010 3:25 PM'],
['LLLL', 'Sunday, February 14 2010 3:25 PM'],
['l', '2/14/2010'],
['ll', 'Feb 14 2010'],
['lll', 'Feb 14 2010 3:25 PM'],
['llll', 'Sun, Feb 14 2010 3:25 PM']
],
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);
test.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
test.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
test.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
test.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
test.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
test.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
test.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
test.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
test.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
test.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
test.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
test.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
test.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
test.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
test.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
test.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
test.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
test.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
test.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
test.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
test.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
test.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
test.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
test.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
test.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
test.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
test.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
test.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
test.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
test.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
test.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
test.done();
},
"format month" : function (test) {
test.expect(12);
var i,
expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
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);
var i,
expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split("_");
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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "a few seconds", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "a minute", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "a minute", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minutes", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minutes", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "an hour", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "an hour", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 hours", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 hours", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 hours", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "a day", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "a day", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 days", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "a day", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 days", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 days", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "a month", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "a month", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "a month", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 months", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 months", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 months", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "a month", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 months", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 months", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "a year", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "a year", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 years", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "a year", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 years", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "in a few seconds", "prefix");
test.equal(moment(0).from(30000), "a few seconds ago", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "a few seconds ago", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "in a few seconds", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "in 5 days", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "Today at 2:00 AM", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Today at 2:25 AM", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Today at 3:00 AM", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "Tomorrow at 2:00 AM", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "Today at 1:00 AM", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "Yesterday at 2:00 AM", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[Last] dddd [at] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[Last] dddd [at] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[Last] dddd [at] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Sunday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 1, "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 7]).week(), 1, "Jan 7 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 2, "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 14]).week(), 2, "Jan 14 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 3, "Jan 15 2012 should be week 3");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(6);
test.equal(moment([2006, 11, 31]).week(), 1, "Dec 31 2006 should be week 1");
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 6]).week(), 1, "Jan 6 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 2, "Jan 7 2007 should be week 2");
test.equal(moment([2007, 0, 13]).week(), 2, "Jan 13 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 3, "Jan 14 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 29]).week(), 52, "Dec 29 2007 should be week 52");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 5]).week(), 1, "Jan 5 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 2, "Jan 6 2008 should be week 2");
test.equal(moment([2008, 0, 12]).week(), 2, "Jan 12 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 3, "Jan 13 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 29]).week(), 1, "Dec 29 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 4]).week(), 1, "Jan 4 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 2, "Jan 5 2003 should be week 2");
test.equal(moment([2003, 0, 11]).week(), 2, "Jan 11 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 3, "Jan 12 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 28]).week(), 1, "Dec 28 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 3]).week(), 1, "Jan 3 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 2, "Jan 4 2009 should be week 2");
test.equal(moment([2009, 0, 10]).week(), 2, "Jan 10 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 3, "Jan 11 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 27]).week(), 1, "Dec 27 2009 should be week 1");
test.equal(moment([2010, 0, 1]).week(), 1, "Jan 1 2010 should be week 1");
test.equal(moment([2010, 0, 2]).week(), 1, "Jan 2 2010 should be week 1");
test.equal(moment([2010, 0, 3]).week(), 2, "Jan 3 2010 should be week 2");
test.equal(moment([2010, 0, 9]).week(), 2, "Jan 9 2010 should be week 2");
test.equal(moment([2010, 0, 10]).week(), 3, "Jan 10 2010 should be week 3");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(5);
test.equal(moment([2010, 11, 26]).week(), 1, "Dec 26 2010 should be week 1");
test.equal(moment([2011, 0, 1]).week(), 1, "Jan 1 2011 should be week 1");
test.equal(moment([2011, 0, 2]).week(), 2, "Jan 2 2011 should be week 2");
test.equal(moment([2011, 0, 8]).week(), 2, "Jan 8 2011 should be week 2");
test.equal(moment([2011, 0, 9]).week(), 3, "Jan 9 2011 should be week 3");
test.done();
},
"weeks year starting sunday format" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1st', "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1st', "Jan 7 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2nd', "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2nd', "Jan 14 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', "Jan 15 2012 should be week 3");
test.done();
}
};

View File

@@ -0,0 +1,359 @@
var moment = require("../../moment");
/**************************************************
Esperanto
*************************************************/
exports["lang:eo"] = {
setUp : function (cb) {
moment.lang('eo');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'januaro jan_februaro feb_marto mar_aprilo apr_majo maj_junio jun_julio jul_aŭgusto aŭg_septembro sep_oktobro okt_novembro nov_decembro dec'.split("_"), 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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'Dimanĉo, februaro 14a 2010, 3:25:50 p.t.m.'],
['ddd, hA', 'Dim, 3P.T.M.'],
['M Mo MM MMMM MMM', '2 2a 02 februaro feb'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14a 14'],
['d do dddd ddd dd', '0 0a Dimanĉo Dim Di'],
['DDD DDDo DDDD', '45 45a 045'],
['w wo ww', '7 7a 07'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'p.t.m. P.T.M.'],
['[la] DDDo [tago] [de] [la] [jaro]', 'la 45a tago de la jaro'],
['L', '2010-02-14'],
['LL', '14-an de februaro, 2010'],
['LLL', '14-an de februaro, 2010 15:25'],
['LLLL', 'Dimanĉo, la 14-an de februaro, 2010 15:25'],
['l', '2010-2-14'],
['ll', '14-an de feb, 2010'],
['lll', '14-an de feb, 2010 15:25'],
['llll', 'Dim, la 14-an de feb, 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);
test.equal(moment([2011, 0, 1]).format('DDDo'), '1a', '1a');
test.equal(moment([2011, 0, 2]).format('DDDo'), '2a', '2a');
test.equal(moment([2011, 0, 3]).format('DDDo'), '3a', '3a');
test.equal(moment([2011, 0, 4]).format('DDDo'), '4a', '4a');
test.equal(moment([2011, 0, 5]).format('DDDo'), '5a', '5a');
test.equal(moment([2011, 0, 6]).format('DDDo'), '6a', '6a');
test.equal(moment([2011, 0, 7]).format('DDDo'), '7a', '7a');
test.equal(moment([2011, 0, 8]).format('DDDo'), '8a', '8a');
test.equal(moment([2011, 0, 9]).format('DDDo'), '9a', '9a');
test.equal(moment([2011, 0, 10]).format('DDDo'), '10a', '10a');
test.equal(moment([2011, 0, 11]).format('DDDo'), '11a', '11a');
test.equal(moment([2011, 0, 12]).format('DDDo'), '12a', '12a');
test.equal(moment([2011, 0, 13]).format('DDDo'), '13a', '13a');
test.equal(moment([2011, 0, 14]).format('DDDo'), '14a', '14a');
test.equal(moment([2011, 0, 15]).format('DDDo'), '15a', '15a');
test.equal(moment([2011, 0, 16]).format('DDDo'), '16a', '16a');
test.equal(moment([2011, 0, 17]).format('DDDo'), '17a', '17a');
test.equal(moment([2011, 0, 18]).format('DDDo'), '18a', '18a');
test.equal(moment([2011, 0, 19]).format('DDDo'), '19a', '19a');
test.equal(moment([2011, 0, 20]).format('DDDo'), '20a', '20a');
test.equal(moment([2011, 0, 21]).format('DDDo'), '21a', '21a');
test.equal(moment([2011, 0, 22]).format('DDDo'), '22a', '22a');
test.equal(moment([2011, 0, 23]).format('DDDo'), '23a', '23a');
test.equal(moment([2011, 0, 24]).format('DDDo'), '24a', '24a');
test.equal(moment([2011, 0, 25]).format('DDDo'), '25a', '25a');
test.equal(moment([2011, 0, 26]).format('DDDo'), '26a', '26a');
test.equal(moment([2011, 0, 27]).format('DDDo'), '27a', '27a');
test.equal(moment([2011, 0, 28]).format('DDDo'), '28a', '28a');
test.equal(moment([2011, 0, 29]).format('DDDo'), '29a', '29a');
test.equal(moment([2011, 0, 30]).format('DDDo'), '30a', '30a');
test.equal(moment([2011, 0, 31]).format('DDDo'), '31a', '31a');
test.done();
},
"format month" : function (test) {
test.expect(12);
var expected = 'januaro jan_februaro feb_marto mar_aprilo apr_majo maj_junio jun_julio jul_aŭgusto aŭg_septembro sep_oktobro okt_novembro nov_decembro dec'.split("_"), 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);
var expected = 'Dimanĉo Dim Di_Lundo Lun Lu_Mardo Mard Ma_Merkredo Merk Me_Ĵaŭdo Ĵaŭ Ĵa_Vendredo Ven Ve_Sabato Sab Sa'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "sekundoj", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "minuto", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "minuto", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minutoj", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minutoj", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "horo", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "horo", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 horoj", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 horoj", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 horoj", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "tago", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "tago", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 tagoj", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "tago", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 tagoj", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 tagoj", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "monato", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "monato", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "monato", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 monatoj", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 monatoj", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 monatoj", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "monato", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 monatoj", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 monatoj", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "jaro", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "jaro", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 jaroj", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "jaro", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 jaroj", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "je sekundoj", "je prefix");
test.equal(moment(0).from(30000), "antaŭ sekundoj", "antaŭ prefix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "antaŭ sekundoj", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "je sekundoj", "je sekundoj");
test.equal(moment().add({d: 5}).fromNow(), "je 5 tagoj", "je 5 tagoj");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "Hodiaŭ je 02:00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Hodiaŭ je 02:25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Hodiaŭ je 03:00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "Morgaŭ je 02:00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "Hodiaŭ je 01:00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "Hieraŭ je 02:00", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [je] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [je] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [je] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[pasinta] dddd [je] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[pasinta] dddd [je] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[pasinta] dddd [je] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Monday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 26]).week(), 1, "Dec 26 2011 should be week 1");
test.equal(moment([2012, 0, 1]).week(), 1, "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 2]).week(), 2, "Jan 2 2012 should be week 2");
test.equal(moment([2012, 0, 8]).week(), 2, "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 9]).week(), 3, "Jan 9 2012 should be week 3");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 12]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 1, "Dec 28 2009 should be week 1");
test.equal(moment([2010, 0, 1]).week(), 1, "Jan 1 2010 should be week 1");
test.equal(moment([2010, 0, 3]).week(), 1, "Jan 3 2010 should be week 1");
test.equal(moment([2010, 0, 4]).week(), 2, "Jan 4 2010 should be week 2");
test.equal(moment([2010, 0, 10]).week(), 2, "Jan 10 2010 should be week 2");
test.equal(moment([2010, 0, 11]).week(), 3, "Jan 11 2010 should be week 3");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 1, "Dec 27 2010 should be week 1");
test.equal(moment([2011, 0, 1]).week(), 1, "Jan 1 2011 should be week 1");
test.equal(moment([2011, 0, 2]).week(), 1, "Jan 2 2011 should be week 1");
test.equal(moment([2011, 0, 3]).week(), 2, "Jan 3 2011 should be week 2");
test.equal(moment([2011, 0, 9]).week(), 2, "Jan 9 2011 should be week 2");
test.equal(moment([2011, 0, 10]).week(), 3, "Jan 10 2011 should be week 3");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1a', "Dec 26 2011 should be week 1");
test.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1a', "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2a', "Jan 2 2012 should be week 2");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2a', "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3a', "Jan 9 2012 should be week 3");
test.done();
}
};

View File

@@ -0,0 +1,354 @@
var moment = require("../../moment");
/**************************************************
Spanish
*************************************************/
exports["lang:es"] = {
setUp : function (cb) {
moment.lang('es');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'enero ene._febrero feb._marzo mar._abril abr._mayo may._junio jun._julio jul._agosto ago._septiembre sep._octubre oct._noviembre nov._diciembre dic.'.split("_"), 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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'domingo, febrero 14º 2010, 3:25:50 pm'],
['ddd, hA', 'dom., 3PM'],
['M Mo MM MMMM MMM', '2 2º 02 febrero feb.'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14º 14'],
['d do dddd ddd dd', '0 0º domingo dom. Do'],
['DDD DDDo DDDD', '45 45º 045'],
['w wo ww', '6 6º 06'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['[the] DDDo [day of the year]', 'the 45º day of the year'],
['L', '14/02/2010'],
['LL', '14 de febrero de 2010'],
['LLL', '14 de febrero de 2010 15:25'],
['LLLL', 'domingo, 14 de febrero de 2010 15:25'],
['l', '14/2/2010'],
['ll', '14 de feb. de 2010'],
['lll', '14 de feb. de 2010 15:25'],
['llll', 'dom., 14 de feb. de 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);
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);
var expected = 'enero ene._febrero feb._marzo mar._abril abr._mayo may._junio jun._julio jul._agosto ago._septiembre sep._octubre oct._noviembre nov._diciembre dic.'.split("_"), 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);
var expected = 'domingo dom. Do_lunes lun. Lu_martes mar. Ma_miércoles mié. Mi_jueves jue. Ju_viernes vie. Vi_sábado sáb. Sá'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "unos segundos", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "un minuto", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "un minuto", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minutos", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minutos", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "una hora", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "una hora", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 horas", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 horas", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 horas", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "un día", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "un día", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 días", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "un día", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 días", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 días", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "un mes", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "un mes", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "un mes", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 meses", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 meses", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 meses", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "un mes", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 meses", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 meses", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "un año", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "un año", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 años", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "un año", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 años", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "en unos segundos", "prefix");
test.equal(moment(0).from(30000), "hace unos segundos", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "hace unos segundos", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "en unos segundos", "en unos segundos");
test.equal(moment().add({d: 5}).fromNow(), "en 5 días", "en 5 días");
test.done();
},
"calendar day" : function (test) {
test.expect(7);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "hoy a las 2:00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "hoy a las 2:25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "hoy a las 3:00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "mañana a las 2:00", "tomorrow at the same time");
test.equal(moment(a).add({ d: 1, h : -1 }).calendar(), "mañana a la 1:00", "tomorrow minus 1 hour");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "hoy a la 1:00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "ayer a las 2:00", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[el] dddd [pasado a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[el] dddd [pasado a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[el] dddd [pasado a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Monday is the first day of the week.
// The week that contains Jan 4th is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 52, "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).week(), 1, "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 1, "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).week(), 2, "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 2, "Jan 15 2012 should be week 2");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 13]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 53, "Dec 28 2009 should be week 53");
test.equal(moment([2010, 0, 1]).week(), 53, "Jan 1 2010 should be week 53");
test.equal(moment([2010, 0, 3]).week(), 53, "Jan 3 2010 should be week 53");
test.equal(moment([2010, 0, 4]).week(), 1, "Jan 4 2010 should be week 1");
test.equal(moment([2010, 0, 10]).week(), 1, "Jan 10 2010 should be week 1");
test.equal(moment([2010, 0, 11]).week(), 2, "Jan 11 2010 should be week 2");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 52, "Dec 27 2010 should be week 52");
test.equal(moment([2011, 0, 1]).week(), 52, "Jan 1 2011 should be week 52");
test.equal(moment([2011, 0, 2]).week(), 52, "Jan 2 2011 should be week 52");
test.equal(moment([2011, 0, 3]).week(), 1, "Jan 3 2011 should be week 1");
test.equal(moment([2011, 0, 9]).week(), 1, "Jan 9 2011 should be week 1");
test.equal(moment([2011, 0, 10]).week(), 2, "Jan 10 2011 should be week 2");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1º', "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', "Jan 15 2012 should be week 2");
test.done();
}
};

View File

@@ -0,0 +1,360 @@
var moment = require("../../moment");
/**************************************************
Estonian
**************************************************/
exports["lang:et"] = {
setUp : function (cb) {
moment.lang('et');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'jaanuar jaan_veebruar veebr_märts märts_aprill apr_mai mai_juuni juuni_juuli juuli_august aug_september sept_oktoober okt_november nov_detsember dets'.split("_"), i;
function equalTest(input, mmm, i) {
test.equal(moment(input, mmm).month(), i, input + ' peaks olema kuu ' + (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(22);
var a = [
['dddd, Do MMMM YYYY, H:mm:ss', 'pühapäev, 14. veebruar 2010, 15:25:50'],
['ddd, h', 'P, 3'],
['M Mo MM MMMM MMM', '2 2. 02 veebruar veebr'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14. 14'],
['d do dddd ddd dd', '0 0. pühapäev P P'],
['DDD DDDo DDDD', '45 45. 045'],
['w wo ww', '6 6. 06'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['[aasta] DDDo [päev]', 'aasta 45. päev'],
['L', '14.02.2010'],
['LL', '14. veebruar 2010'],
['LLL', '14. veebruar 2010 15:25'],
['LLLL', 'pühapäev, 14. veebruar 2010 15:25'],
['l', '14.2.2010'],
['ll', '14. veebr 2010'],
['lll', '14. veebr 2010 15:25'],
['llll', 'P, 14. veebr 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);
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);
var expected = 'jaanuar jaan_veebruar veebr_märts märts_aprill apr_mai mai_juuni juuni_juuli juuli_august aug_september sept_oktoober okt_november nov_detsember dets'.split("_"), 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);
var expected = 'pühapäev P P_esmaspäev E E_teisipäev T T_kolmapäev K K_neljapäev N N_reede R R_laupäev L L'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "paari sekundi", "44 seconds = paari sekundi");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "minut", "45 seconds = minut");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "minut", "89 seconds = minut");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minutit", "90 seconds = 2 minutit");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minutit", "44 minutes = 44 minutit");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "tund", "45 minutes = tund");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "tund", "89 minutes = tund");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 tundi", "90 minutes = 2 tundi");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 tundi", "5 hours = 5 tundi");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 tundi", "21 hours = 21 tundi");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "päev", "22 hours = päev");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "päev", "35 hours = päev");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 päeva", "36 hours = 2 päeva");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "päev", "1 day = päev");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 päeva", "5 days = 5 päeva");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 päeva", "25 days = 25 päeva");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "kuu", "26 days = kuu");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "kuu", "30 days = kuu");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "kuu", "45 days = kuu");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 kuud", "46 days = 2 kuud");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 kuud", "75 days = 2 kuud");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 kuud", "76 days = 3 kuud");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "kuu", "1 month = kuu");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 kuud", "5 months = 5 kuud");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 kuud", "344 days = 11 kuud");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "aasta", "345 days = aasta");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "aasta", "547 days = aasta");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 aastat", "548 days = 2 aastat");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "aasta", "1 year = aasta");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 aastat", "5 years = 5 aastat");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "paari sekundi pärast", "prefix");
test.equal(moment(0).from(30000), "paar sekundit tagasi", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "paar sekundit tagasi", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "paari sekundi pärast", "paari sekundi pärast");
test.equal(moment().add({d: 5}).fromNow(), "5 päeva pärast", "5 päeva pärast");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "Täna, 2:00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Täna, 2:25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Täna, 3:00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "Homme, 2:00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "Täna, 1:00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "Eile, 2:00", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('[Järgmine] dddd LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[Järgmine] dddd LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[Järgmine] dddd LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[Eelmine] dddd LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[Eelmine] dddd LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[Eelmine] dddd LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
weeksFromNow = moment().add({ w: 1 });
test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 nädal tagasi");
test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "1 nädala pärast");
weeksAgo = moment().subtract({ w: 2 });
weeksFromNow = moment().add({ w: 2 });
test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 nädalat tagasi");
test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "2 nädala pärast");
test.done();
},
// Monday is the first day of the week.
// The week that contains Jan 4th is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 52, "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).week(), 1, "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 1, "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).week(), 2, "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 2, "Jan 15 2012 should be week 2");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 13]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 53, "Dec 28 2009 should be week 53");
test.equal(moment([2010, 0, 1]).week(), 53, "Jan 1 2010 should be week 53");
test.equal(moment([2010, 0, 3]).week(), 53, "Jan 3 2010 should be week 53");
test.equal(moment([2010, 0, 4]).week(), 1, "Jan 4 2010 should be week 1");
test.equal(moment([2010, 0, 10]).week(), 1, "Jan 10 2010 should be week 1");
test.equal(moment([2010, 0, 11]).week(), 2, "Jan 11 2010 should be week 2");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 52, "Dec 27 2010 should be week 52");
test.equal(moment([2011, 0, 1]).week(), 52, "Jan 1 2011 should be week 52");
test.equal(moment([2011, 0, 2]).week(), 52, "Jan 2 2011 should be week 52");
test.equal(moment([2011, 0, 3]).week(), 1, "Jan 3 2011 should be week 1");
test.equal(moment([2011, 0, 9]).week(), 1, "Jan 9 2011 should be week 1");
test.equal(moment([2011, 0, 10]).week(), 2, "Jan 10 2011 should be week 2");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', "Jan 15 2012 should be week 2");
test.done();
}
};

View File

@@ -0,0 +1,356 @@
var moment = require("../../moment");
/**************************************************
Euskara
*************************************************/
exports["lang:eu"] = {
setUp : function (cb) {
moment.lang('eu');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'urtarrila urt._otsaila ots._martxoa mar._apirila api._maiatza mai._ekaina eka._uztaila uzt._abuztua abu._iraila ira._urria urr._azaroa aza._abendua abe.'.split("_"), 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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'igandea, otsaila 14. 2010, 3:25:50 pm'],
['ddd, hA', 'ig., 3PM'],
['M Mo MM MMMM MMM', '2 2. 02 otsaila ots.'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14. 14'],
['d do dddd ddd dd', '0 0. igandea ig. ig'],
['DDD DDDo DDDD', '45 45. 045'],
['w wo ww', '7 7. 07'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['[the] DDDo [day of the year]', 'the 45. day of the year'],
['L', '2010-02-14'],
['LL', '2010ko otsailaren 14a'],
['LLL', '2010ko otsailaren 14a 15:25'],
['LLLL', 'igandea, 2010ko otsailaren 14a 15:25'],
['l', '2010-2-14'],
['ll', '2010ko ots. 14a'],
['lll', '2010ko ots. 14a 15:25'],
['llll', 'ig., 2010ko ots. 14a 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);
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);
var expected = 'urtarrila urt._otsaila ots._martxoa mar._apirila api._maiatza mai._ekaina eka._uztaila uzt._abuztua abu._iraila ira._urria urr._azaroa aza._abendua abe.'.split("_"), 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);
var expected = 'igandea ig. ig_astelehena al. al_asteartea ar. ar_asteazkena az. az_osteguna og. og_ostirala ol. ol_larunbata lr. lr'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "segundo batzuk", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "minutu bat", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "minutu bat", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minutu", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minutu", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "ordu bat", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "ordu bat", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 ordu", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 ordu", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 ordu", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "egun bat", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "egun bat", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 egun", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "egun bat", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 egun", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 egun", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "hilabete bat", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "hilabete bat", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "hilabete bat", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 hilabete", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 hilabete", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 hilabete", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "hilabete bat", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 hilabete", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 hilabete", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "urte bat", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "urte bat", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 urte", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "urte bat", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 urte", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "segundo batzuk barru", "prefix");
test.equal(moment(0).from(30000), "duela segundo batzuk", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "duela segundo batzuk", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "segundo batzuk barru", "in seconds");
test.equal(moment().add({d: 5}).fromNow(), "5 egun barru", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "gaur 02:00etan", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "gaur 02:25etan", "now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "gaur 03:00etan", "now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "bihar 02:00etan", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "gaur 01:00etan", "now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "atzo 02:00etan", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd LT[etan]'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd LT[etan]'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd LT[etan]'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[aurreko] dddd LT[etan]'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[aurreko] dddd LT[etan]'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[aurreko] dddd LT[etan]'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Monday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 26]).week(), 1, "Dec 26 2011 should be week 1");
test.equal(moment([2012, 0, 1]).week(), 1, "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 2]).week(), 2, "Jan 2 2012 should be week 2");
test.equal(moment([2012, 0, 8]).week(), 2, "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 9]).week(), 3, "Jan 9 2012 should be week 3");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 12]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 1, "Dec 28 2009 should be week 1");
test.equal(moment([2010, 0, 1]).week(), 1, "Jan 1 2010 should be week 1");
test.equal(moment([2010, 0, 3]).week(), 1, "Jan 3 2010 should be week 1");
test.equal(moment([2010, 0, 4]).week(), 2, "Jan 4 2010 should be week 2");
test.equal(moment([2010, 0, 10]).week(), 2, "Jan 10 2010 should be week 2");
test.equal(moment([2010, 0, 11]).week(), 3, "Jan 11 2010 should be week 3");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 1, "Dec 27 2010 should be week 1");
test.equal(moment([2011, 0, 1]).week(), 1, "Jan 1 2011 should be week 1");
test.equal(moment([2011, 0, 2]).week(), 1, "Jan 2 2011 should be week 1");
test.equal(moment([2011, 0, 3]).week(), 2, "Jan 3 2011 should be week 2");
test.equal(moment([2011, 0, 9]).week(), 2, "Jan 9 2011 should be week 2");
test.equal(moment([2011, 0, 10]).week(), 3, "Jan 10 2011 should be week 3");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', "Dec 26 2011 should be week 1");
test.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', "Jan 2 2012 should be week 2");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', "Jan 9 2012 should be week 3");
test.done();
}
};

View File

@@ -0,0 +1,338 @@
// moment.js Persian (fa) tests
// author: Ebrahim Byagowi : https://github.com/ebraminio
var moment = require("../../moment");
exports["lang:fa"] = {
setUp : function (cb) {
moment.lang('fa');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(24);
var tests = انویه_فوریهارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split("_"), i;
function equalTest(input, mmm, i) {
test.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' instead is month ' + moment(input, mmm).month());
}
for (i = 0; i < 12; i++) {
equalTest(tests[i], 'MMM', i);
equalTest(tests[i], 'MMMM', i);
}
test.done();
},
"format" : function (test) {
test.expect(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'یک\u200cشنبه، فوریه ۱۴م ۲۰۱۰، ۳:۲۵:۵۰ بعد از ظهر'],
['ddd, hA', 'یک\u200cشنبه، ۳بعد از ظهر'],
['M Mo MM MMMM MMM', '۲ ۲م ۰۲ فوریه فوریه'],
['YYYY YY', '۲۰۱۰ ۱۰'],
['D Do DD', '۱۴ ۱۴م ۱۴'],
['d do dddd ddd dd', '۰ ۰م یک\u200cشنبه یک\u200cشنبه ی'],
['DDD DDDo DDDD', '۴۵ ۴۵م ۰۴۵'],
['w wo ww', '۸ ۸م ۰۸'],
['h hh', '۳ ۰۳'],
['H HH', '۱۵ ۱۵'],
['m mm', '۲۵ ۲۵'],
['s ss', '۵۰ ۵۰'],
['a A', 'بعد از ظهر بعد از ظهر'],
['DDDo [روز سال]', '۴۵م روز سال'],
['L', '۱۴/۰۲/۲۰۱۰'],
['LL', '۱۴ فوریه ۲۰۱۰'],
['LLL', '۱۴ فوریه ۲۰۱۰ ۱۵:۲۵'],
['LLLL', 'یک\u200cشنبه، ۱۴ فوریه ۲۰۱۰ ۱۵:۲۵'],
['l', '۱۴/۲/۲۰۱۰'],
['ll', '۱۴ فوریه ۲۰۱۰'],
['lll', '۱۴ فوریه ۲۰۱۰ ۱۵:۲۵'],
['llll', 'یک\u200cشنبه، ۱۴ فوریه ۲۰۱۰ ۱۵:۲۵']
],
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);
test.equal(moment([2011, 0, 1]).format('DDDo'), '۱م', '1');
test.equal(moment([2011, 0, 2]).format('DDDo'), '۲م', '2');
test.equal(moment([2011, 0, 3]).format('DDDo'), '۳م', '3');
test.equal(moment([2011, 0, 4]).format('DDDo'), '۴م', '4');
test.equal(moment([2011, 0, 5]).format('DDDo'), '۵م', '5');
test.equal(moment([2011, 0, 6]).format('DDDo'), '۶م', '6');
test.equal(moment([2011, 0, 7]).format('DDDo'), '۷م', '7');
test.equal(moment([2011, 0, 8]).format('DDDo'), '۸م', '8');
test.equal(moment([2011, 0, 9]).format('DDDo'), '۹م', '9');
test.equal(moment([2011, 0, 10]).format('DDDo'), '۱۰م', '10');
test.equal(moment([2011, 0, 11]).format('DDDo'), '۱۱م', '11');
test.equal(moment([2011, 0, 12]).format('DDDo'), '۱۲م', '12');
test.equal(moment([2011, 0, 13]).format('DDDo'), '۱۳م', '13');
test.equal(moment([2011, 0, 14]).format('DDDo'), '۱۴م', '14');
test.equal(moment([2011, 0, 15]).format('DDDo'), '۱۵م', '15');
test.equal(moment([2011, 0, 16]).format('DDDo'), '۱۶م', '16');
test.equal(moment([2011, 0, 17]).format('DDDo'), '۱۷م', '17');
test.equal(moment([2011, 0, 18]).format('DDDo'), '۱۸م', '18');
test.equal(moment([2011, 0, 19]).format('DDDo'), '۱۹م', '19');
test.equal(moment([2011, 0, 20]).format('DDDo'), '۲۰م', '20');
test.equal(moment([2011, 0, 21]).format('DDDo'), '۲۱م', '21');
test.equal(moment([2011, 0, 22]).format('DDDo'), '۲۲م', '22');
test.equal(moment([2011, 0, 23]).format('DDDo'), '۲۳م', '23');
test.equal(moment([2011, 0, 24]).format('DDDo'), '۲۴م', '24');
test.equal(moment([2011, 0, 25]).format('DDDo'), '۲۵م', '25');
test.equal(moment([2011, 0, 26]).format('DDDo'), '۲۶م', '26');
test.equal(moment([2011, 0, 27]).format('DDDo'), '۲۷م', '27');
test.equal(moment([2011, 0, 28]).format('DDDo'), '۲۸م', '28');
test.equal(moment([2011, 0, 29]).format('DDDo'), '۲۹م', '29');
test.equal(moment([2011, 0, 30]).format('DDDo'), '۳۰م', '30');
test.equal(moment([2011, 0, 31]).format('DDDo'), '۳۱م', '31');
test.done();
},
"format month" : function (test) {
test.expect(12);
var expected = 'ژانویه ژانویه_فوریه فوریهارس مارس_آوریل آوریل_مه مه_ژوئن ژوئن_ژوئیه ژوئیه_اوت اوت_سپتامبر سپتامبر_اکتبر اکتبر_نوامبر نوامبر_دسامبر دسامبر'.split("_"), 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);
var expected = 'یک\u200cشنبه یک\u200cشنبه ی_دوشنبه دوشنبه د_سه\u200cشنبه سه\u200cشنبه س_چهارشنبه چهارشنبه چ_پنج\u200cشنبه پنج\u200cشنبه پ_جمعه جمعه ج_شنبه شنبه ش'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "چندین ثانیه", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "یک دقیقه", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "یک دقیقه", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "۲ دقیقه", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "۴۴ دقیقه", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "یک ساعت", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "یک ساعت", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "۲ ساعت", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "۵ ساعت", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "۲۱ ساعت", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "یک روز", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "یک روز", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "۲ روز", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "یک روز", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "۵ روز", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "۲۵ روز", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "یک ماه", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "یک ماه", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "یک ماه", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "۲ ماه", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "۲ ماه", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "۳ ماه", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "یک ماه", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "۵ ماه", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "۱۱ ماه", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "یک سال", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "یک سال", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "۲ سال", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "یک سال", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "۵ سال", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "در چندین ثانیه", "prefix");
test.equal(moment(0).from(30000), "چندین ثانیه پیش", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "چندین ثانیه پیش", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "در چندین ثانیه", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "در ۵ روز", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "امروز ساعت ۰۲:۰۰", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "امروز ساعت ۰۲:۲۵", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "امروز ساعت ۰۳:۰۰", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "فردا ساعت ۰۲:۰۰", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "امروز ساعت ۰۱:۰۰", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "دیروز ساعت ۰۲:۰۰", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [ساعت] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [ساعت] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [ساعت] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('dddd [پیش ساعت] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [پیش ساعت] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [پیش ساعت] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Saturday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 31]).week(), 1, "Dec 31 2011 should be week 1");
test.equal(moment([2012, 0, 6]).week(), 1, "Jan 6 2012 should be week 1");
test.equal(moment([2012, 0, 7]).week(), 2, "Jan 7 2012 should be week 2");
test.equal(moment([2012, 0, 13]).week(), 2, "Jan 13 2012 should be week 2");
test.equal(moment([2012, 0, 14]).week(), 3, "Jan 14 2012 should be week 3");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2006, 11, 30]).week(), 1, "Dec 30 2006 should be week 1");
test.equal(moment([2007, 0, 5]).week(), 1, "Jan 5 2007 should be week 1");
test.equal(moment([2007, 0, 6]).week(), 2, "Jan 6 2007 should be week 2");
test.equal(moment([2007, 0, 12]).week(), 2, "Jan 12 2007 should be week 2");
test.equal(moment([2007, 0, 13]).week(), 3, "Jan 13 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 29]).week(), 1, "Dec 29 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 4]).week(), 1, "Jan 4 2008 should be week 1");
test.equal(moment([2008, 0, 5]).week(), 2, "Jan 5 2008 should be week 2");
test.equal(moment([2008, 0, 11]).week(), 2, "Jan 11 2008 should be week 2");
test.equal(moment([2008, 0, 12]).week(), 3, "Jan 12 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 28]).week(), 1, "Dec 28 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 3]).week(), 1, "Jan 3 2003 should be week 1");
test.equal(moment([2003, 0, 4]).week(), 2, "Jan 4 2003 should be week 2");
test.equal(moment([2003, 0, 10]).week(), 2, "Jan 10 2003 should be week 2");
test.equal(moment([2003, 0, 11]).week(), 3, "Jan 11 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 27]).week(), 1, "Dec 27 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 2]).week(), 1, "Jan 2 2009 should be week 1");
test.equal(moment([2009, 0, 3]).week(), 2, "Jan 3 2009 should be week 2");
test.equal(moment([2009, 0, 9]).week(), 2, "Jan 9 2009 should be week 2");
test.equal(moment([2009, 0, 10]).week(), 3, "Jan 10 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(5);
test.equal(moment([2009, 11, 26]).week(), 1, "Dec 26 2009 should be week 1");
test.equal(moment([2010, 0, 1]).week(), 1, "Jan 1 2010 should be week 1");
test.equal(moment([2010, 0, 2]).week(), 2, "Jan 2 2010 should be week 2");
test.equal(moment([2010, 0, 8]).week(), 2, "Jan 8 2010 should be week 2");
test.equal(moment([2010, 0, 9]).week(), 3, "Jan 9 2010 should be week 3");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(5);
test.equal(moment([2011, 0, 1]).week(), 1, "Jan 1 2011 should be week 1");
test.equal(moment([2011, 0, 7]).week(), 1, "Jan 7 2011 should be week 1");
test.equal(moment([2011, 0, 8]).week(), 2, "Jan 8 2011 should be week 2");
test.equal(moment([2011, 0, 14]).week(), 2, "Jan 14 2011 should be week 2");
test.equal(moment([2011, 0, 15]).week(), 3, "Jan 15 2011 should be week 3");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2011, 11, 31]).format('w ww wo'), '۱ ۰۱ ۱م', "Dec 31 2011 should be week 1");
test.equal(moment([2012, 0, 6]).format('w ww wo'), '۱ ۰۱ ۱م', "Jan 6 2012 should be week 1");
test.equal(moment([2012, 0, 7]).format('w ww wo'), '۲ ۰۲ ۲م', "Jan 7 2012 should be week 2");
test.equal(moment([2012, 0, 13]).format('w ww wo'), '۲ ۰۲ ۲م', "Jan 13 2012 should be week 2");
test.equal(moment([2012, 0, 14]).format('w ww wo'), '۳ ۰۳ ۳م', "Jan 14 2012 should be week 3");
test.done();
}
};

View File

@@ -0,0 +1,351 @@
var moment = require("../../moment");
/**************************************************
Finnish
*************************************************/
exports["lang:fi"] = {
setUp : function (cb) {
moment.lang('fi');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var tests = 'tammikuu tammi_helmikuu helmi_maaliskuu maalis_huhtikuu huhti_toukokuu touko_kesäkuu kesä_heinäkuu heinä_elokuu elo_syyskuu syys_lokakuu loka_marraskuu marras_joulukuu joulu'.split("_"), 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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'sunnuntai, helmikuu 14. 2010, 3:25:50 pm'],
['ddd, hA', 'su, 3PM'],
['M Mo MM MMMM MMM', '2 2. 02 helmikuu helmi'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14. 14'],
['d do dddd ddd dd', '0 0. sunnuntai su su'],
['DDD DDDo DDDD', '45 45. 045'],
['w wo ww', '6 6. 06'],
['h hh', '3 03'],
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['[vuoden] DDDo [päivä]', 'vuoden 45. päivä'],
['L', '14.02.2010'],
['LL', '14. helmikuuta 2010'],
['LLL', '14. helmikuuta 2010, klo 15.25'],
['LLLL', 'sunnuntai, 14. helmikuuta 2010, klo 15.25'],
['l', '14.2.2010'],
['ll', '14. helmi 2010'],
['lll', '14. helmi 2010, klo 15.25'],
['llll', 'su, 14. helmi 2010, klo 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);
test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1st');
test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2nd');
test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3rd');
test.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4th');
test.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5th');
test.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6th');
test.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7th');
test.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8th');
test.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9th');
test.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10th');
test.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11th');
test.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12th');
test.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13th');
test.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14th');
test.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15th');
test.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16th');
test.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17th');
test.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18th');
test.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19th');
test.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20th');
test.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21st');
test.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22nd');
test.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23rd');
test.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24th');
test.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25th');
test.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26th');
test.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27th');
test.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28th');
test.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29th');
test.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30th');
test.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31st');
test.done();
},
"format month" : function (test) {
test.expect(12);
var expected = 'tammikuu tammi_helmikuu helmi_maaliskuu maalis_huhtikuu huhti_toukokuu touko_kesäkuu kesä_heinäkuu heinä_elokuu elo_syyskuu syys_lokakuu loka_marraskuu marras_joulukuu joulu'.split("_"), 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);
var expected = 'sunnuntai su su_maanantai ma ma_tiistai ti ti_keskiviikko ke ke_torstai to to_perjantai pe pe_lauantai la la'.split("_"), 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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "muutama sekunti", "44 seconds = few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "minuutti", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "minuutti", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "kaksi minuuttia", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minuuttia", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "tunti", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "tunti", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "kaksi tuntia", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "viisi tuntia", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 tuntia", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "päivä", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "päivä", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "kaksi päivää", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "päivä", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "viisi päivää", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 päivää", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "kuukausi", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "kuukausi", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "kuukausi", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "kaksi kuukautta", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "kaksi kuukautta", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "kolme kuukautta", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "kuukausi", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "viisi kuukautta", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 kuukautta", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "vuosi", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "vuosi", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "kaksi vuotta", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "vuosi", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "viisi vuotta", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "muutaman sekunnin päästä", "prefix");
test.equal(moment(0).from(30000), "muutama sekunti sitten", "suffix");
test.done();
},
"now from now" : function (test) {
test.expect(1);
test.equal(moment().fromNow(), "muutama sekunti sitten", "now from now should display as in the past");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "muutaman sekunnin päästä", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "viiden päivän päästä", "in 5 days");
test.done();
},
"calendar day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "tänään klo 02.00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "tänään klo 02.25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "tänään klo 03.00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "huomenna klo 02.00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "tänään klo 01.00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "eilen klo 02.00", "yesterday at the same time");
test.done();
},
"calendar next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [klo] LT'), "today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [klo] LT'), "today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [klo] LT'), "today + " + i + " days end of day");
}
test.done();
},
"calendar last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('[viime] dddd[na] [klo] LT'), "today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('[viime] dddd[na] [klo] LT'), "today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('[viime] dddd[na] [klo] LT'), "today - " + i + " days end of day");
}
test.done();
},
"calendar all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
weeksFromNow = moment().add({ w: 1 });
test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "yksi viikko sitten");
test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "yhden viikon päästä");
weeksAgo = moment().subtract({ w: 2 });
weeksFromNow = moment().add({ w: 2 });
test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "kaksi viikkoa sitten");
test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "kaden viikon päästä");
test.done();
},
// Monday is the first day of the week.
// The week that contains Jan 4th is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 52, "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).week(), 1, "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 1, "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).week(), 2, "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 2, "Jan 15 2012 should be week 2");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(5);
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 1, "Jan 7 2007 should be week 1");
test.equal(moment([2007, 0, 8]).week(), 2, "Jan 8 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 2, "Jan 14 2007 should be week 2");
test.equal(moment([2007, 0, 15]).week(), 3, "Jan 15 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 31]).week(), 1, "Dec 31 2007 should be week 1");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 1, "Jan 6 2008 should be week 1");
test.equal(moment([2008, 0, 7]).week(), 2, "Jan 7 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 2, "Jan 13 2008 should be week 2");
test.equal(moment([2008, 0, 14]).week(), 3, "Jan 14 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 30]).week(), 1, "Dec 30 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 1, "Jan 5 2003 should be week 1");
test.equal(moment([2003, 0, 6]).week(), 2, "Jan 6 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 2, "Jan 12 2003 should be week 2");
test.equal(moment([2003, 0, 13]).week(), 3, "Jan 13 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 29]).week(), 1, "Dec 29 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 1, "Jan 4 2009 should be week 1");
test.equal(moment([2009, 0, 5]).week(), 2, "Jan 5 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 2, "Jan 11 2009 should be week 2");
test.equal(moment([2009, 0, 13]).week(), 3, "Jan 12 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 28]).week(), 53, "Dec 28 2009 should be week 53");
test.equal(moment([2010, 0, 1]).week(), 53, "Jan 1 2010 should be week 53");
test.equal(moment([2010, 0, 3]).week(), 53, "Jan 3 2010 should be week 53");
test.equal(moment([2010, 0, 4]).week(), 1, "Jan 4 2010 should be week 1");
test.equal(moment([2010, 0, 10]).week(), 1, "Jan 10 2010 should be week 1");
test.equal(moment([2010, 0, 11]).week(), 2, "Jan 11 2010 should be week 2");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(6);
test.equal(moment([2010, 11, 27]).week(), 52, "Dec 27 2010 should be week 52");
test.equal(moment([2011, 0, 1]).week(), 52, "Jan 1 2011 should be week 52");
test.equal(moment([2011, 0, 2]).week(), 52, "Jan 2 2011 should be week 52");
test.equal(moment([2011, 0, 3]).week(), 1, "Jan 3 2011 should be week 1");
test.equal(moment([2011, 0, 9]).week(), 1, "Jan 9 2011 should be week 1");
test.equal(moment([2011, 0, 10]).week(), 2, "Jan 10 2011 should be week 2");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', "Jan 1 2012 should be week 52");
test.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', "Jan 2 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', "Jan 8 2012 should be week 1");
test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', "Jan 9 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', "Jan 15 2012 should be week 2");
test.done();
}
};

View File

@@ -0,0 +1,371 @@
var moment = require("../../moment");
/**************************************************
French (Canadian)
*************************************************/
exports["lang:fr-ca"] = {
setUp : function (cb) {
moment.lang('fr-ca');
cb();
},
tearDown : function (cb) {
moment.lang('en');
cb();
},
"parse" : function (test) {
test.expect(96);
var i,
tests = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split("_");
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(22);
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'dimanche, février 14 2010, 3:25:50 pm'],
['ddd, hA', 'dim., 3PM'],
['M Mo MM MMMM MMM', '2 2 02 février févr.'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14 14'],
['d do dddd ddd dd', '0 0 dimanche dim. Di'],
['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'],
['[the] DDDo [day of the year]', 'the 45 day of the year'],
['L', '2010-02-14'],
['LL', '14 février 2010'],
['LLL', '14 février 2010 15:25'],
['LLLL', 'dimanche 14 février 2010 15:25'],
['l', '2010-2-14'],
['ll', '14 févr. 2010'],
['lll', '14 févr. 2010 15:25'],
['llll', 'dim. 14 févr. 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);
test.equal(moment([2011, 0, 1]).format('DDDo'), '1er', '1er');
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);
var i,
expected = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split("_");
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);
var i,
expected = 'dimanche dim. Di_lundi lun. Lu_mardi mar. Ma_mercredi mer. Me_jeudi jeu. Je_vendredi ven. Ve_samedi sam. Sa'.split("_");
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);
var start = moment([2007, 1, 28]);
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "quelques secondes", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "une minute", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "une minute", "89 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minutes", "90 seconds = 2 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minutes", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "une heure", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "une heure", "89 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 heures", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 heures", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 heures", "21 hours = 21 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "un jour", "22 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "un jour", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 jours", "36 hours = 2 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "un jour", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 jours", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 jours", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "un mois", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "un mois", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "un mois", "45 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 mois", "46 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 mois", "75 days = 2 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 mois", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "un mois", "1 month = a month");
test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 mois", "5 months = 5 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 mois", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "un an", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "un an", "547 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 ans", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "un an", "1 year = a year");
test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 ans", "5 years = 5 years");
test.done();
},
"suffix" : function (test) {
test.expect(2);
test.equal(moment(30000).from(0), "dans quelques secondes", "prefix");
test.equal(moment(0).from(30000), "il y a quelques secondes", "suffix");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
test.equal(moment().add({s: 30}).fromNow(), "dans quelques secondes", "in a few seconds");
test.equal(moment().add({d: 5}).fromNow(), "dans 5 jours", "in 5 days");
test.done();
},
"same day" : function (test) {
test.expect(6);
var a = moment().hours(2).minutes(0).seconds(0);
test.equal(moment(a).calendar(), "Aujourd'hui à 02:00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Aujourd'hui à 02:25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Aujourd'hui à 03:00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "Demain à 02:00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "Aujourd'hui à 01:00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "Hier à 02:00", "yesterday at the same time");
test.done();
},
"same next week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format('dddd [à] LT'), "Today + " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [à] LT'), "Today + " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [à] LT'), "Today + " + i + " days end of day");
}
test.done();
},
"same last week" : function (test) {
test.expect(15);
var i, m;
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format('dddd [dernier à] LT'), "Today - " + i + " days current time");
m.hours(0).minutes(0).seconds(0).milliseconds(0);
test.equal(m.calendar(), m.format('dddd [dernier à] LT'), "Today - " + i + " days beginning of day");
m.hours(23).minutes(59).seconds(59).milliseconds(999);
test.equal(m.calendar(), m.format('dddd [dernier à] LT'), "Today - " + i + " days end of day");
}
test.done();
},
"same all else" : function (test) {
test.expect(4);
var weeksAgo = moment().subtract({ w: 1 }),
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();
},
// Sunday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
"weeks year starting sunday" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).week(), 1, "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 7]).week(), 1, "Jan 7 2012 should be week 1");
test.equal(moment([2012, 0, 8]).week(), 2, "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 14]).week(), 2, "Jan 14 2012 should be week 2");
test.equal(moment([2012, 0, 15]).week(), 3, "Jan 15 2012 should be week 3");
test.done();
},
"weeks year starting monday" : function (test) {
test.expect(6);
test.equal(moment([2006, 11, 31]).week(), 1, "Dec 31 2006 should be week 1");
test.equal(moment([2007, 0, 1]).week(), 1, "Jan 1 2007 should be week 1");
test.equal(moment([2007, 0, 6]).week(), 1, "Jan 6 2007 should be week 1");
test.equal(moment([2007, 0, 7]).week(), 2, "Jan 7 2007 should be week 2");
test.equal(moment([2007, 0, 13]).week(), 2, "Jan 13 2007 should be week 2");
test.equal(moment([2007, 0, 14]).week(), 3, "Jan 14 2007 should be week 3");
test.done();
},
"weeks year starting tuesday" : function (test) {
test.expect(6);
test.equal(moment([2007, 11, 29]).week(), 52, "Dec 29 2007 should be week 52");
test.equal(moment([2008, 0, 1]).week(), 1, "Jan 1 2008 should be week 1");
test.equal(moment([2008, 0, 5]).week(), 1, "Jan 5 2008 should be week 1");
test.equal(moment([2008, 0, 6]).week(), 2, "Jan 6 2008 should be week 2");
test.equal(moment([2008, 0, 12]).week(), 2, "Jan 12 2008 should be week 2");
test.equal(moment([2008, 0, 13]).week(), 3, "Jan 13 2008 should be week 3");
test.done();
},
"weeks year starting wednesday" : function (test) {
test.expect(6);
test.equal(moment([2002, 11, 29]).week(), 1, "Dec 29 2002 should be week 1");
test.equal(moment([2003, 0, 1]).week(), 1, "Jan 1 2003 should be week 1");
test.equal(moment([2003, 0, 4]).week(), 1, "Jan 4 2003 should be week 1");
test.equal(moment([2003, 0, 5]).week(), 2, "Jan 5 2003 should be week 2");
test.equal(moment([2003, 0, 11]).week(), 2, "Jan 11 2003 should be week 2");
test.equal(moment([2003, 0, 12]).week(), 3, "Jan 12 2003 should be week 3");
test.done();
},
"weeks year starting thursday" : function (test) {
test.expect(6);
test.equal(moment([2008, 11, 28]).week(), 1, "Dec 28 2008 should be week 1");
test.equal(moment([2009, 0, 1]).week(), 1, "Jan 1 2009 should be week 1");
test.equal(moment([2009, 0, 3]).week(), 1, "Jan 3 2009 should be week 1");
test.equal(moment([2009, 0, 4]).week(), 2, "Jan 4 2009 should be week 2");
test.equal(moment([2009, 0, 10]).week(), 2, "Jan 10 2009 should be week 2");
test.equal(moment([2009, 0, 11]).week(), 3, "Jan 11 2009 should be week 3");
test.done();
},
"weeks year starting friday" : function (test) {
test.expect(6);
test.equal(moment([2009, 11, 27]).week(), 1, "Dec 27 2009 should be week 1");
test.equal(moment([2010, 0, 1]).week(), 1, "Jan 1 2010 should be week 1");
test.equal(moment([2010, 0, 2]).week(), 1, "Jan 2 2010 should be week 1");
test.equal(moment([2010, 0, 3]).week(), 2, "Jan 3 2010 should be week 2");
test.equal(moment([2010, 0, 9]).week(), 2, "Jan 9 2010 should be week 2");
test.equal(moment([2010, 0, 10]).week(), 3, "Jan 10 2010 should be week 3");
test.done();
},
"weeks year starting saturday" : function (test) {
test.expect(5);
test.equal(moment([2010, 11, 26]).week(), 1, "Dec 26 2010 should be week 1");
test.equal(moment([2011, 0, 1]).week(), 1, "Jan 1 2011 should be week 1");
test.equal(moment([2011, 0, 2]).week(), 2, "Jan 2 2011 should be week 2");
test.equal(moment([2011, 0, 8]).week(), 2, "Jan 8 2011 should be week 2");
test.equal(moment([2011, 0, 9]).week(), 3, "Jan 9 2011 should be week 3");
test.done();
},
"weeks year starting sunday format" : function (test) {
test.expect(5);
test.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1er', "Jan 1 2012 should be week 1");
test.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1er', "Jan 7 2012 should be week 1");
test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', "Jan 8 2012 should be week 2");
test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', "Jan 14 2012 should be week 2");
test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', "Jan 15 2012 should be week 3");
test.done();
}
};

Some files were not shown because too many files have changed in this diff Show More