On Tue, Dec 28, 2021 at 9:12 PM Stefano Miccoli <stefano.micc...@polimi.it>
wrote:
Hi Stefano,


> Nice overview!
>
Thanks!


> Of course the first sentence should be “leap years”, which leads to my
> main point.
>
Sure, I've already fixed this one, it just hasn't found its way online yet.


> It makes no sense to claim “leap year support” without specifying the
> relevant calendar. Thus I would suggest to clearly state, from the very
> begin of this section, that
>
It is not a matter of formal definitions. Leap seconds are
uncompromisingly practical.
If you look at the wall clock on 1 Jan 1970 00:00 and then look at the same
clock today and measure the difference with atomic clock you won't get the
time delta that np.timedelta64 reports. There will be a difference of ~37
seconds.
One would expect that a library claiming to work with attoseconds would at
least count the seconds correctly )

Astropy library calculates
<https://het.as.utexas.edu/HET/Software/Astropy-1.0/api/astropy.time.TimeGPS.html>
them properly:
"GPS Time. Seconds from 1980-01-06 00:00:00 UTC For example, 630720013.0 is
midnight on January 1, 2000."
>>> np.datetime64('2000-01-01', 's') - np.datetime64('1980-01-06', 's')
numpy.timedelta64(630720000,'s')

Everything should be made as simple as possible but not simpler. Leap
seconds are an inherent part of the world we live in.

Eg this is how people deal with them currently: they have to parse times
like 23:59:60.209215 manually
https://stackoverflow.com/questions/21027639/python-datetime-not-accounting-for-leap-second-properly

- calendrical calculations are performed using a proleptic Gregorian
> calendar <https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar>,
> - Posix semantics is followed, i.e. each day comprises exactly 86400 SI
> seconds, thus ignoring the existence of leap seconds.
>
> I would also point out that this choice is consistent with python datetime.
>
But not consistent with python time ;) "Unlike the time module, the
datetime module does not support leap seconds."
• time.CLOCK_TAI
    International Atomic Time
   The system must have a current leap second table in order for this to
give the correct answer. PTP or NTP software can maintain a leap second
table.
    Availability: Linux.
    New in version 3.9.


> As what regards the promised future support for leap seconds, I would not
> mention it, for now. In fact leap second support requires a leap second
> table, which is not available on all platforms supported by numpy.
> Therefore the leap second table should be bundled and updated with every
> numpy release with the very undesirable effect that older version (with
> outdated tables) would behave differently from newer ones.
>
The olson database is much larger yet it is updated on millions of
computers, phones and what not without causing extra difficulties
(except when the government unexpectedly decides to shift a region from one
TZ to another). This way developers have a choice whether
to work with naive datetimes (ok in a single timezone without
daylight-saving) or with timezone-aware ones (and take care about updating
the pytz).

This is how astropy deals with updating the table:
https://docs.astropy.org/en/stable/api/astropy.utils.iers.LeapSeconds.html
Pytz also has this table both inside the binary tz files and in a text
file: https://github.com/stub42/pytz/blob/master/tz/leap-seconds.list
which it in turn downloads from NIST
ftp://ftp.nist.gov/pub/time/leap-seconds.list
It is in the public domain, NIST updates this file regularly and it even
has an expiration date (presently it is 28 June 2022).
Activation of the 'leap-second-aware mode' could be made dependent on the
presence of the pytz mode and/or this expiration date.

I don't think having a non-default leap-second-aware mode would hurt
anyone, but I also wouldn't consider it a priority. I think when someone
needs them he'll make a patch and until that moment it is safe to have them
as 'proposed' )

I feel that leap seconds should be mentioned somewhere—in the article or in
the docs, because it limits practical precise usage of timedelta64 to
a period between 2021 and 2016 (last time when a leap second was injected).
A modest timespan for a library claiming to work with years upto 9.2e18
BC ;)

Thank you for your suggestions! I've included them into the article, plz
have a look at the updated version.

Best regards,
Lev

Stefano
>
> _______________________________________________
> NumPy-Discussion mailing list -- numpy-discussion@python.org
> To unsubscribe send an email to numpy-discussion-le...@python.org
> https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
> Member address: lev.maxi...@gmail.com
>
_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to