Skip to content

Commit

Permalink
parse unix timestamps with decimal points (issue 826)
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Apr 9, 2011
1 parent b110e2b commit be32715
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/date_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ function parseDate(s, ignoreTimezone) { // ignoreTimezone defaults to true
return new Date(s * 1000);
}
if (typeof s == 'string') {
if (s.match(/^\d+$/)) { // a UNIX timestamp
return new Date(parseInt(s, 10) * 1000);
if (s.match(/^\d+(\.\d+)?$/)) { // a UNIX timestamp
return new Date(parseFloat(s) * 1000);
}
if (ignoreTimezone === undefined) {
ignoreTimezone = true;
Expand Down
4 changes: 4 additions & 0 deletions tests/sources.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
start: new Date(y, m, 28),
end: new Date(y, m, 29),
url: 'http://google.com/'
},
{
title: 'Float String Timestamp Event',
start: '1295078400.0'
}
];

Expand Down

0 comments on commit be32715

Please sign in to comment.