Skip to content

Commit a900aa0

Browse files
committed
Undo prior changes by @Ivanca on 2014/01/03; we do want floating point numbers as decimals of seconds are allowed (e.g., for our example in date_parse()); also fix missing unmatched expression
1 parent f879f27 commit a900aa0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

functions/datetime/strtotime.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ function strtotime(text, now) {
3535
.toLowerCase();
3636

3737
if (text === 'now') {
38-
return now === null || isNaN(now) ? new Date().getTime() / 1000 | 0 : now | 0;
38+
return now === null || isNaN(now) ? new Date().getTime() / 1000 : now;
3939
}
4040

41-
match = text.match(/^(\d{2,4})-(\d{2})-(\d{2})(?:\s(\d{1,2}):(\d{2})(?::\d{2})?)?(?:\.(\d+)?)?$/);
41+
match = text.match(/^(\d{2,4})-(\d{2})-(\d{2})(?:\s(\d{1,2}):(\d{2})(?::(\d{2}))?)?(?:\.(\d+)?)?$/);
4242
if (match) {
4343
year = match[1] >= 0 && match[1] <= 69 ? + match[1] + 2000 : match[1];
4444
return new Date(year, parseInt(match[2], 10) - 1, match[3],
45-
match[4] || 0, match[5] || 0, match[6] || 0, match[7] || 0) / 1000 | 0;
45+
match[4] || 0, match[5] || 0, match[6] || 0, match[7] || 0) / 1000;
4646
}
4747

4848
date = now ? new Date(now * 1000) : new Date();
@@ -131,5 +131,5 @@ function strtotime(text, now) {
131131
//if (!match.every(process))
132132
// return false;
133133

134-
return (date.getTime() / 1000) | 0;
134+
return (date.getTime() / 1000);
135135
}

0 commit comments

Comments
 (0)