1 | strftime
|
2 | ========
|
3 |
|
4 | strftime for JavaScript, supports localization.
|
5 |
|
6 |
|
7 | Installation
|
8 | ============
|
9 |
|
10 | npm install strftime
|
11 |
|
12 |
|
13 | Usage
|
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 |
|
19 | If 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 |
|
36 | And 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 |
|
43 | For details just see `man 3 strftime` as the format specifiers are identical.
|
44 |
|
45 | License
|
46 | =======
|
47 |
|
48 | Copyright 2010 - 2011 Sami Samhuri sami.samhuri@gmail.com
|
49 |
|
50 | MIT (see included [LICENSE](/samsonjs/strftime/blob/master/LICENSE))
|