question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`datetime.timestamp` returns `float`, but Arrow's returns `int`

See original GitHub issue

As mentioned in https://github.com/crsmithdev/arrow/pull/464 (thanks @zmwangx!), Python 3.3 added a datetime.timestamp() method returning a float with microsecond precision. Unfortunately, Arrow already has an Arrow.timestamp property, which is an int with second precision.

As Arrow is intended to be a drop-in replacement for datetime, my opinion is that this forces us to implement a timestamp method as well. We can implement this and maintain backwards compatibility if the timestamp property returned an int-like object that, when called, returned a float. Accessing it like a property could be accompanied with a DeprecationWarning so we could remove this hack eventually.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jadchaarcommented, Apr 6, 2019

Hi @Syeberman, I am looking to fix this issue and was wondering where to start. I was looking at arrow.py and noticed that there is a float_timestamp method, and was wondering if this is as simple as creating a method called timestamp() and simply mimicking the functionality of float_timestamp (reducing duplicate code of course). Any input is appreciated 😄 .

0reactions
systemcatchcommented, May 29, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

datetime.timestamp returns float , but Arrow's returns int #465
Python 3.3 added a datetime.timestamp() method returning a float with microsecond precision. Unfortunately, Arrow already has an Arrow.timestamp property, ...
Read more >
Timestamp with utc and any other timezone is coming out to ...
Constructs an Arrow object from a timestamp, converted to the given timezone. Parameters: timestamp – an int or float timestamp, or a str...
Read more >
Arrow: Better dates & times for Python — Arrow 1.2.3 ...
Arrow is a Python library that offers a sensible and human-friendly approach to creating, manipulating, formatting and converting dates, times and timestamps.
Read more >
Complete Guide To Arrow: A Python Library for User-friendly ...
Arrow is a flexible Python library designed to handle dates, time, and timestamps in a sensible and human-friendly manner.
Read more >
How to convert a float to timestamp or datetime?
When I try below method, I get errors about conversion. Cast(dbo.DateAndFracAsUnix(TimestampUTC, FractionOfASecond) as timestamp). Code Snippet.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found