mirror of
https://github.com/samsonjs/strftime.git
synced 2026-04-25 14:37:39 +00:00
update readme
This commit is contained in:
parent
7a807339ce
commit
da0563dda7
1 changed files with 27 additions and 3 deletions
30
Readme.md
30
Readme.md
|
|
@ -1,7 +1,7 @@
|
||||||
strftime
|
strftime
|
||||||
========
|
========
|
||||||
|
|
||||||
strftime for JavaScript
|
strftime for JavaScript, supports localization.
|
||||||
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
|
|
@ -14,13 +14,37 @@ Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
var strftime = require('strftime').strftime
|
var strftime = require('strftime').strftime
|
||||||
console.log(strftime('%d-%m-%y %H:%M:%S')) // => 11-11-2010 13:24:17
|
console.log(strftime('%B %d, %y %H:%M:%S')) // => April 28, 2011 18:21:08
|
||||||
|
|
||||||
|
If you want to localize it:
|
||||||
|
|
||||||
|
var strftime = require('strftime').strftime
|
||||||
|
var it_IT = {
|
||||||
|
days: [ 'domenica', 'lunedi', 'martedi', 'mercoledi', 'giovedi', 'venerdi', 'sabato' ],
|
||||||
|
shortDays: [ 'dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab' ],
|
||||||
|
|
||||||
|
months: [ 'gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio',
|
||||||
|
'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre' ],
|
||||||
|
|
||||||
|
shortMonths: [ 'gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago',
|
||||||
|
'set', 'ott', 'nov', 'dic' ],
|
||||||
|
AM: 'AM',
|
||||||
|
PM: 'PM'
|
||||||
|
}
|
||||||
|
console.log(strftime('%B %d, %y %H:%M:%S', it_IT)) // => aprile 28, 2011 18:21:08
|
||||||
|
|
||||||
|
And if you don't want to pass a localization object every time you can get a localized `strftime` function like so:
|
||||||
|
|
||||||
|
var strftime = require('strftime')
|
||||||
|
var it_IT = { /* same as above */ }
|
||||||
|
var strftime_IT = strftime.getLocalizedStrftime(it_IT)
|
||||||
|
console.log(strftime_IT('%B %d, %y %H:%M:%S')) // aprile 28, 2011 18:21:08
|
||||||
|
|
||||||
For details just see `man 3 strftime` as the format specifiers are identical.
|
For details just see `man 3 strftime` as the format specifiers are identical.
|
||||||
|
|
||||||
License
|
License
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Copyright 2010 Sami Samhuri sami.samhuri@gmail.com
|
Copyright 2010 - 2011 Sami Samhuri sami.samhuri@gmail.com
|
||||||
|
|
||||||
MIT (see included [LICENSE](/samsonjs/strftime/blob/master/LICENSE))
|
MIT (see included [LICENSE](/samsonjs/strftime/blob/master/LICENSE))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue