Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No test for Unix timestamp; failing new test case? #214

Closed
sanmai-NL opened this issue Jan 25, 2018 · 3 comments
Closed

No test for Unix timestamp; failing new test case? #214

sanmai-NL opened this issue Jan 25, 2018 · 3 comments

Comments

@sanmai-NL
Copy link

sanmai-NL commented Jan 25, 2018

I didn’t discover a unit test for parsing a Unix timestamp ("%s"). This test case fails, why?

let time_zero = DateTime::parse_from_str("0", "%s").unwrap();
panicked at 'called `Result::unwrap()` on an `Err` value: ParseError(NotEnough)', libcore/result.rs:916:5
@quodlibetor
Copy link
Contributor

You need to use a NaiveDateTime if you don't have a timezone (which timestamps don't). Also I don't believe that this will work correctly until 0.4.1 is released, which will be soon.

@smallsweet
Copy link

Hi, I am also confused.
Even if using a DateTime<FixedOffset> I would assume all timestamps converted using %s to be in UTC, since that's part of the definition itself.

%s | 994518299 | UNIX timestamp, the number of seconds since 1970-01-01 00:00 UTC. [7]

@pitdicker
Copy link
Collaborator

Fixed in #1136.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants