UNPKG

1.51 kBMarkdownView Raw
1strftime
2========
3
4strftime for JavaScript, supports localization.
5
6
7Installation
8============
9
10npm install strftime
11
12
13Usage
14=====
15
16 var strftime = require('strftime').strftime
17 console.log(strftime('%B %d, %y %H:%M:%S')) // => April 28, 2011 18:21:08
18
19If you want to localize it:
20
21 var strftime = require('strftime').strftime
22 var it_IT = {
23 days: [ 'domenica', 'lunedi', 'martedi', 'mercoledi', 'giovedi', 'venerdi', 'sabato' ],
24 shortDays: [ 'dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab' ],
25
26 months: [ 'gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio',
27 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre' ],
28
29 shortMonths: [ 'gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago',
30 'set', 'ott', 'nov', 'dic' ],
31 AM: 'AM',
32 PM: 'PM'
33 }
34 console.log(strftime('%B %d, %y %H:%M:%S', it_IT)) // => aprile 28, 2011 18:21:08
35
36And if you don't want to pass a localization object every time you can get a localized `strftime` function like so:
37
38 var strftime = require('strftime')
39 var it_IT = { /* same as above */ }
40 var strftime_IT = strftime.getLocalizedStrftime(it_IT)
41 console.log(strftime_IT('%B %d, %y %H:%M:%S')) // aprile 28, 2011 18:21:08
42
43For details just see `man 3 strftime` as the format specifiers are identical.
44
45License
46=======
47
48Copyright 2010 - 2011 Sami Samhuri sami.samhuri@gmail.com
49
50MIT (see included [LICENSE](/samsonjs/strftime/blob/master/LICENSE))