|
1 |
| -function strtotime (text, now) { |
| 1 | + |
| 2 | +function strtotime(text, now) { |
2 | 3 | // Convert string representation of date and time to a timestamp
|
3 | 4 | //
|
4 | 5 | // version: 1109.2015
|
@@ -36,21 +37,12 @@ function strtotime (text, now) {
|
36 | 37 | if (text === 'now') {
|
37 | 38 | return now === null || isNaN(now) ? new Date().getTime() / 1000 | 0 : now | 0;
|
38 | 39 | }
|
39 |
| - if (!isNaN(parsed = Date.parse(text))) { |
40 |
| - return parsed / 1000 | 0; |
41 |
| - } |
42 |
| - if (text === 'now') { |
43 |
| - return new Date().getTime() / 1000; // Return seconds, not milli-seconds |
44 |
| - } |
45 |
| - if (!isNaN(parsed = Date.parse(text))) { |
46 |
| - return parsed / 1000; |
47 |
| - } |
48 | 40 |
|
49 | 41 | match = text.match(/^(\d{2,4})-(\d{2})-(\d{2})(?:\s(\d{1,2}):(\d{2})(?::\d{2})?)?(?:\.(\d+)?)?$/);
|
50 | 42 | if (match) {
|
51 |
| - year = match[1] >= 0 && match[1] <= 69 ? +match[1] + 2000 : match[1]; |
| 43 | + year = match[1] >= 0 && match[1] <= 69 ? + match[1] + 2000 : match[1]; |
52 | 44 | return new Date(year, parseInt(match[2], 10) - 1, match[3],
|
53 |
| - match[4] || 0, match[5] || 0, match[6] || 0, match[7] || 0) / 1000; |
| 45 | + match[4] || 0, match[5] || 0, match[6] || 0, match[7] || 0) / 1000 | 0; |
54 | 46 | }
|
55 | 47 |
|
56 | 48 | date = now ? new Date(now * 1000) : new Date();
|
@@ -139,5 +131,5 @@ function strtotime (text, now) {
|
139 | 131 | //if (!match.every(process))
|
140 | 132 | // return false;
|
141 | 133 |
|
142 |
| - return (date.getTime() / 1000); |
| 134 | + return (date.getTime() / 1000) | 0; |
143 | 135 | }
|
0 commit comments