View Single Post
Old 03-26-2021, 07:31 PM   #29
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,774
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Thumbs up

Quote:
Originally Posted by ownedbycats View Post
Also I was experimenting and came across something strange

The highest date available in the Calibre date fields seems to be 9999-12-31 so I put this in:

Code:
program:
	format_date('9999-12-31T23:59:59+00:00', 'to_number')
which resulted in 253402300799.0

So I put that back in this:

Code:
program:
	format_date('253402300799.0', 'from_number')
and got a BAD DATE error. I wonder why. maybe I put the date in wrong the first template.
You have found one of the fundamental problems with timestamps: they can represent only a subset of dates. Exactly what that subset is depends on the platform.

For example, on windows this expression works:
Code:
	format_date(1031*(365*24*60*60), 'from_number')
The number is (approximately) 1032 years in the future from the epoch. It produces 3000-04-26T01:00:00+01:00.

The 2032 year-in-the-future expression
Code:
	format_date(1032*(365*24*60*60), 'from_number')
produces "BAD DATE", which means that python threw an exception.

For more bad news see Year 2038 problem.

Bottom line: you can't trust timestamps.
chaley is offline   Reply With Quote