1 | "use strict";
|
2 |
|
3 | var months = require("months"),
|
4 | days = require("days"),
|
5 | fillo = require("fillo"),
|
6 | ParseIt = require("parse-it").Parser;
|
7 |
|
8 | var parser = new ParseIt({
|
9 |
|
10 |
|
11 | "YYYY": function YYYY(i) {
|
12 | return i.getFullYear();
|
13 | }
|
14 |
|
15 |
|
16 | , "YY": function YY(i) {
|
17 | return i.getFullYear() % 100;
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 | , "MMMM": function MMMM(i) {
|
23 | return months[i.getMonth()];
|
24 | }
|
25 |
|
26 |
|
27 | , "MMM": function MMM(i) {
|
28 | return months.abbr[i.getMonth()];
|
29 | }
|
30 |
|
31 |
|
32 | , "MM": function MM(i) {
|
33 | return fillo(i.getMonth() + 1);
|
34 | }
|
35 |
|
36 |
|
37 | , "M": function M(i) {
|
38 | return i.getMonth() + 1;
|
39 | }
|
40 |
|
41 |
|
42 |
|
43 | , "dddd": function dddd(i) {
|
44 | return days[i.getDay()];
|
45 | }
|
46 |
|
47 | , "ddd": function ddd(i) {
|
48 | return days.abbr[i.getDay()];
|
49 | }
|
50 |
|
51 | , "dd": function dd(i) {
|
52 | return days.short[i.getDay()];
|
53 | }
|
54 |
|
55 | , "d": function d(i) {
|
56 | return i.getDay();
|
57 | }
|
58 |
|
59 |
|
60 |
|
61 | , "DD": function DD(i) {
|
62 | return fillo(i.getDate());
|
63 | }
|
64 |
|
65 | , "D": function D(i) {
|
66 | return i.getDate();
|
67 | }
|
68 |
|
69 |
|
70 |
|
71 | , "A": function A(i) {
|
72 | return i.getHours() >= 12 ? "PM" : "AM";
|
73 | }
|
74 |
|
75 | , "a": function a(i) {
|
76 | return i.getHours() >= 12 ? "pm" : "am";
|
77 | }
|
78 |
|
79 |
|
80 |
|
81 | , "hh": function hh(i) {
|
82 | return fillo(i.getHours() % 12 || 12);
|
83 | }
|
84 |
|
85 | , "h": function h(i) {
|
86 | return i.getHours() % 12 || 12;
|
87 | }
|
88 |
|
89 | , "HH": function HH(i) {
|
90 | return fillo(i.getHours());
|
91 | }
|
92 |
|
93 | , "H": function H(i) {
|
94 | return i.getHours();
|
95 | }
|
96 |
|
97 |
|
98 |
|
99 | , "mm": function mm(i) {
|
100 | return fillo(i.getMinutes());
|
101 | }
|
102 |
|
103 | , "m": function m(i) {
|
104 | return i.getMinutes();
|
105 | }
|
106 |
|
107 |
|
108 |
|
109 | , "ss": function ss(i) {
|
110 | return fillo(i.getSeconds());
|
111 | }
|
112 |
|
113 |
|
114 | , "s": function s(i) {
|
115 | return i.getSeconds();
|
116 | }
|
117 | });
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | module.exports = function formatoid(i, f) {
|
163 | return parser.run(f, [i]);
|
164 | }; |
\ | No newline at end of file |