mktime, how to handle dates before 01-01-1970 ?

Ben Finney ben+python at benfinney.id.au
Mon Oct 5 21:12:45 EDT 2009


Ben Finney <ben+python at benfinney.id.au> writes:

> There are many epochs that have been used in computing
> <URL:http://en.wikipedia.org/wiki/Epoch_(reference_date)#Notable_epoch_dates_in_computing>,
> all of which have their problems. Switching from the Unix epoch to some
> other involves data conversion, and (as you point out) raises concerns
> about library support.

Hmm, none of this addressed your question about what *data type* to use.
For that, the answer is: use the standard-library ‘datetime’ module's
types (‘date’, ‘timestamp’, etc.) in your code for representing the
actual values.

The advice for date and time values is similar to the advice for text
values: convert input to ‘datetime’ types as soon as possible, and
render output as late as possible; do all processing on the ‘datetime’
types to ensure preservation of information.

-- 
 \        “I filled my humidifier with wax. Now my room is all shiny.” |
  `\                                                    —Steven Wright |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list