arrow-py / arrow

🏹 Better dates & times for Python
https://arrow.readthedocs.io
Apache License 2.0
8.71k stars 673 forks source link

Is timestamp a property? #928

Closed loverdos closed 3 years ago

loverdos commented 3 years ago

Issue Description

In the documentation, timestamp is treated as a property and so no parentheses are used but in the code it is not declared as a property, so parentheses are used. In fact, if we try to @property-ize it, tests fail. This hints at fixing the documentation vs fixing the code, so the purpose of the ticket is to ask the question and help provide a definitive answer. Once the intention is clarified, I can provide the relevant patch.

System Info

jadchaar commented 3 years ago

Hi @loverdos, thanks for bringing this up. This is actually a part of the documentation we forgot to update for the v1.0 release. We now have a few ways to access timestamps:

env ❯ python3
Python 3.9.2 (default, Feb 19 2021, 17:43:04)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> arrow.__version__
'1.0.1'
>>> now = arrow.now()
>>> now
<Arrow [2021-02-27T14:06:09.855717-05:00]>
>>> now.timestamp()
1614452769.855717
>>> now.int_timestamp
1614452769
>>> now.float_timestamp
1614452769.855717

The int_timestamp and float_timestamp properties were added in v1.0 for legacy purposes. The primary way to access timestamps is to now use the function.