forked from hogart/datef
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maxim Ponomarev
committed
Oct 7, 2014
1 parent
92fc45d
commit 919246b
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('cz', { | ||
_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('_') | ||
}, | ||
months: function (date, format) { | ||
var nounCase = /dd?\s*MMMM?/.test(format) ? 'accusative' : 'nominative'; | ||
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('_') | ||
}, | ||
monthsShort: function (date, format) { | ||
var nounCase = /dd?\s*MMMM?/.test(format) ? 'accusative' : 'nominative'; | ||
return this._monthsShort[nounCase][date.getMonth()]; | ||
}, | ||
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('_'), | ||
meridiem : function (hour) { | ||
if (hour < 12) { | ||
return 'dopoledne'; | ||
} else { | ||
return 'odpoledne'; | ||
} | ||
} | ||
}); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var datef = require('../../datef'); | ||
require('chai').should(); | ||
|
||
describe('Czech laguage (cz)', function() { | ||
beforeEach(function() { | ||
datef.lang('cz'); | ||
}); | ||
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) { | ||
datef('MMMM', '2008-' + (index + 1) + '-05').should.be.equal(month); | ||
}); | ||
'ledna_února_března_dubna_května_června_července_září_října_listopadu_prosince'.split('_').forEach(function(month, index) { | ||
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) { | ||
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); | ||
}); | ||
'po_út_stř_čt_pá_so_ne'.split('_').forEach(function(day, index) { | ||
datef('D', '2014-09-' + (index + 1)).should.be.equal(day); | ||
}); | ||
}); | ||
}); |