Skip to content

Commit

Permalink
pull hogart's master
Browse files Browse the repository at this point in the history
  • Loading branch information
maxvipon committed Oct 28, 2015
2 parents 2bd8828 + 5dbfcf6 commit 45d1306
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 14 deletions.
32 changes: 32 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "datef",
"version": "0.2.0",
"description": "Simple date formatting library, both for browser and node.js",
"main": "datef.js",
"homepage": "https://github.com/hogart/datef",
"license": "MIT",

"keywords": [
"moment",
"date",
"time",
"format",
"l10n"
],

"authors": [
"Konstantin Kitmanov <[email protected]>",
"Maxim Ponomarev <[email protected]>"
],

"repository": {
"type": "git",
"url": "git://github.com/hogart/datef.git"
},

"moduleType": [
"amd",
"globals",
"node"
]
}
6 changes: 3 additions & 3 deletions lang/cz.js → lang/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
factory(window.datef);
}
}(function (datef) {
datef.lang('cz', {
datef.lang('cs', {
_months: {
nominative: 'leden_únor_březen_duben_květen_červen_červenec_září_říjen_listopad_prosinec'.split('_'),
accusative: 'ledna_února_března_dubna_května_června_července_září_října_listopadu_prosince'.split('_')
Expand All @@ -17,8 +17,8 @@
return this._months[nounCase][date.getMonth()];
},
_monthsShort: {
nominative: 'led_ún_bř_dub_kvě_čer_čerc_srp_zář_říj_lis_pros'.split('_'),
accusative: 'led_ún_bř_dub_kvě_čer_čerc_srp_zář_říj_lis_pros'.split('_')
nominative: 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_'),
accusative: 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_')
},
monthsShort: function (date, format) {
var nounCase = /dd?\s*MMMM?/.test(format) ? 'accusative' : 'nominative';
Expand Down
38 changes: 38 additions & 0 deletions lang/pl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['datef'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('../datef'));
} else {
factory(window.datef);
}
}(function (datef) {
datef.lang('pl', {
_months: {
nominative: 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpeń_wrzesień_październik_listopad_grudzień'.split('_'),
accusative: 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_październik_listopada_grudnia'.split('_')
},
months: function (date, format) {
var nounCase = /dd?\s*MMMM?/.test(format) ? 'accusative' : 'nominative';
return this._months[nounCase][date.getMonth()];
},
_monthsShort: {
nominative: 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'),
accusative: 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_')
},
monthsShort: function (date, format) {
var nounCase = /dd?\s*MMMM?/.test(format) ? 'accusative' : 'nominative';
return this._monthsShort[nounCase][date.getMonth()];
},
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('_'),
meridiem : function (hour) {
if (hour < 12) {
return 'rano';
} else {
return '';
}
}
});
}));
3 changes: 2 additions & 1 deletion test/lang/be.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ describe('Belarusian language (be)', function() {
datef('MMM', '2008-' + (index + 1) + '-05').should.be.equal(month);
});
'панядзелак_аўторак_серада_чацвер_пятніца_субота_нядзеля'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('DDD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'пн_аўт_сер_чц_пт_сб_ндз'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('D', '2014-09-' + (index + 1)).should.be.equal(day);
});
});
Expand Down
9 changes: 5 additions & 4 deletions test/lang/cz.js → test/lang/cs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var datef = require('../../datef');
require('chai').should();

describe('Czech language (cz)', function() {
describe('Czech language (cs)', function() {
beforeEach(function() {
datef.lang('cz');
datef.lang('cs');
});
it('should correct format the date', function() {
'leden_únor_březen_duben_květen_červen_červenec_září_říjen_listopad_prosinec'.split('_').forEach(function(month, index) {
Expand All @@ -13,13 +13,14 @@ describe('Czech language (cz)', function() {
var matcher = new RegExp('^\\d ' + month + '$');
datef('d MMMM', '2008-' + (index + 1) + '-05').should.be.match(matcher);
});
'led_ún_bř_dub_kvě_čer_čerc_srp_zář_říj_lis_pros'.split('_').forEach(function(month, index) {
'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_').forEach(function(month, index) {
datef('MMM', '2008-' + (index + 1) + '-05').should.be.equal(month);
});
'pondělí_úterý_středa_čtvrtek_pátek_sobota_neděle'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('DDD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'po_út_stř_čt_pá_so_ne'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('D', '2014-09-' + (index + 1)).should.be.equal(day);
});
});
Expand Down
3 changes: 3 additions & 0 deletions test/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe('English language (en)', function() {
datef('MMM', '2008-' + (index + 1) + '-05').should.be.equal(month);
});
'Monday_Tuesday_Wednesday_Thursday_Friday_Saturday_Sunday'.split('_').forEach(function(day, index) {
datef('DDD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'Mon_Tue_Wed_Thu_Fri_Sat_Sun'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'Mo_Tu_We_Th_Fr_Sa_Su'.split('_').forEach(function(day, index) {
Expand Down
3 changes: 2 additions & 1 deletion test/lang/kk.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ describe('Kazakh language (kk)', function() {
datef('MMM', '2008-' + (index + 1) + '-05').should.be.equal(month);
});
'дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі_жексенбі'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('DDD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'дс_сн_ср_бс_жм_сб_жк'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('D', '2014-09-' + (index + 1)).should.be.equal(day);
});
});
Expand Down
25 changes: 25 additions & 0 deletions test/lang/pl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var datef = require('../../datef');
require('chai').should();

describe('Polish language (pl)', function() {
beforeEach(function() {
datef.lang('pl');
});
it('should correct format the date', function() {
'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpeń_wrzesień_październik_listopad_grudzień'.split('_').forEach(function(month, index) {
datef('MMMM', '2008-' + (index + 1) + '-05').should.be.equal(month);
});
'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_').forEach(function(month, index) {
datef('MMM', '2008-' + (index + 1) + '-05').should.be.equal(month);
});
'poniedziałek_wtorek_środa_czwartek_piątek_sobota_niedziela'.split('_').forEach(function(day, index) {
datef('DDD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'pon_wt_śr_czw_pt_sb_nie'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'Pn_Wt_Śr_Cz_Pt_So_N'.split('_').forEach(function(day, index) {
datef('D', '2014-09-' + (index + 1)).should.be.equal(day);
});
});
});
3 changes: 2 additions & 1 deletion test/lang/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ describe('Russian language (ru)', function() {
datef('MMM', '2008-' + (index + 1) + '-05').should.be.equal(month);
});
'понедельник_вторник_среда_четверг_пятница_суббота_воскресенье'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('DDD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'пн_вт_ср_чт_пт_сб_вс'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('D', '2014-09-' + (index + 1)).should.be.equal(day);
});
});
Expand Down
3 changes: 3 additions & 0 deletions test/lang/tr.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe('Turkish language (tr)', function() {
datef('MMM', '2008-' + (index + 1) + '-05').should.be.equal(month);
});
'Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi_Pazar'.split('_').forEach(function(day, index) {
datef('DDD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'Pts_Sal_Çar_Per_Cum_Cts_Paz'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'Pt_Sa_Ça_Pe_Cu_Ct_Pz'.split('_').forEach(function(day, index) {
Expand Down
3 changes: 2 additions & 1 deletion test/lang/tt.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ describe('Tatar language (tt)', function() {
datef('MMM', '2008-' + (index + 1) + '-05').should.be.equal(month);
});
'дүшәмбе_сишәмбе_чәршәмбе_пәнҗешәмбе_җомга_шимбә_якшәмбе'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('DDD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'дш_сш_чш_пш_җм_шм_як'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('D', '2014-09-' + (index + 1)).should.be.equal(day);
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/lang/uk.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ describe('Ukrainian language (uk)', function() {
datef('MMM', '2008-' + (index + 1) + '-05').should.be.equal(month);
});
'понеділок_вівторок_середа_четвер_п’ятниця_субота_неділя'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('DDD', '2014-09-' + (index + 1)).should.be.equal(day);
});
'пн_вт_ср_чт_пт_сб_нд'.split('_').forEach(function(day, index) {
datef('DD', '2014-09-' + (index + 1)).should.be.equal(day);
datef('D', '2014-09-' + (index + 1)).should.be.equal(day);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/test.format.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('format', function() {
datef('f', '2008-03-05T00:00:00.100Z').should.be.equal('100');
datef('A', '2008-03-05T00:00:00Z').should.match(/^AM|PM$/);
datef('a', '2008-03-05T00:00:00Z').should.match(/^am|pm$/);
datef('ZZ', '2008-03-05').should.match(/^[-+]\d{4}$/);
datef('Z', '2008-03-05').should.match(/^[-+]\d{2}:\d{2}$/);
datef('ZZ', '2008-03-05').should.match(/^[-+]\d{4}$/);
});
});
2 changes: 1 addition & 1 deletion test/test.formatters.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var datef = require('../datef');
require('chai').should();

describe('language', function() {
describe('formatters', function() {
beforeEach(function() {
datef.lang('en');
});
Expand Down

0 comments on commit 45d1306

Please sign in to comment.