[Tutor] python at midnight
ingoogni at gmail.com
Sun Nov 14 20:06:40 CET 2010
While processing weather data from the http://www.knmi.nl/ and
building a small domotica system I ran into the following
from the python doc:
"class datetime.datetime(year, month, day[, hour[, minute[, second[,
The year, month and day arguments are required. tzinfo may be None, or
an instance of a tzinfo subclass. The remaining arguments may be ints
or longs, in the following ranges:
0 <= hour < 24
If an argument outside those ranges is given, ValueError is raised."
from http://en.wikipedia.org/wiki/ISO_8601 :
"ISO 8601 uses the 24-hour clock system. The basic format is
[hh][mm][ss] and the extended format is [hh]:[mm]:[ss].
* [hh] refers to a zero-padded hour between 00 and 24 (where 24 is
only used to notate midnight at the end of a calendar day).
Midnight is a special case and can be referred to as both "00:00" and
"24:00". The notation "00:00" is used at the beginning of a calendar
day and is the more frequently used. At the end of a day use "24:00".
Note that "2007-04-05T24:00" is the same instant as "2007-04-06T00:00"
(see Combined date and time representations below)."
The use of 24:00 is very comfortable when using hourly datasets, the
first set of a day is saved under 1:00, the fifth (4:00 to 5:00) under
5:00 and the last (23:00 - 24:00) under 24:00. No need to suddenly use
23:59:59 or 0:00 the next day. Actually in another part of Python
SQLlite's date and time functions accept and output the 24:00. Adding
some Python to an existing database made me aware of the problem.
Is there a date time library that accepts the 24:00? mxDateTime doesn't.
Is there a way to set the limit 'from the outside' (subclassing???) or
a simple way around?
How to get this functionality added to Python?
More information about the Tutor