empirical-soft / empirical-lang

A language for time-series analysis
https://www.empirical-soft.com/
Other
167 stars 13 forks source link

Unexpected Timestamp behavior #32

Closed andrewnc closed 4 years ago

andrewnc commented 4 years ago

This very well could be expected behavior, and my inexperience working with datetimes is coming through. In the case below, I would have expected the date to be at the beginning of January 1st, instead of at the end.

>>> Timestamp("1946-01-01") Timestamp("1946-01-02 00:00:00")

chrisaycock commented 4 years ago

Ah, this appears to be a limitation of how I handle negative offsets from the Unix epoch (1970-01-01). It looks like non-leap years are aren't being calculated correctly.

>>> Timestamp("1960-01-01")
Timestamp("1960-01-01 00:00:00")

>>> Timestamp("1961-01-01")
Timestamp("1961-01-02 00:00:00")

>>> Timestamp("1962-01-01")
Timestamp("1962-01-02 00:00:00")

>>> Timestamp("1963-01-01")
Timestamp("1963-01-02 00:00:00")

>>> Timestamp("1964-01-01")
Timestamp("1964-01-01 00:00:00")