[Numpy-discussion] fixing up datetime
Mon Jun 6 04:43:21 CDT 2011
On Mon, Jun 6, 2011 at 8:16 AM, Mark Dickinson <firstname.lastname@example.org> wrote:
> On Thu, Jun 2, 2011 at 5:42 PM, Mark Wiebe <email@example.com> wrote:
>> Leap years are easy compared with leap seconds. Leap seconds involve a
>> hardcoded table of particular leap-seconds that are added or subtracted, and
>> are specified roughly 6 months in advance of when they happen by
>> the International Earth Rotation and Reference Systems Service (IERS). The
>> POSIX time_t doesn't store leap seconds, so if you subtract two time_t
>> values you may get the wrong answer by up to 34 seconds (or 24, I'm not
>> totally clear on the initial 10 second jump that happened somewhere).
> Times in the future would be hairy, too. If leap seconds are
> supported, how many seconds are there in the timedelta:
> 2015-01-01 00:00:00 - 2010-01-01 00:00:00
> ? Is it acceptable for the result of the subtraction like this to
> change when the leap second table is updated (e.g., to reflect a newly
> added leap second on June 30th, 2012)?
> NumPy-Discussion mailing list
Tangential to the technical details being discussed, but my $0.02 on
One thing I tried to do in pandas is enable the implementation of
custom time deltas ("date offsets" in pandas parlance). For example,
let's say add 5 weekdays (or business days) to a particular date. Now,
there are some arbitrary choices you have to make, e.g. what do you do
when the date being added to is not a business day? If you look in
you can see some examples. Things are a bit of a mess in places but
the key ideas are there. One nice thing about this framework is that
you can create subclasses of DateOffset that connect to some external
source of information, e.g. trading exchange information-- so if you
want to shift by "trading days" for that exchange-- e.g. include
holidays and other closures, you can do that relatively seamlessly.
Downside is that it's fairly slow generally speaking.
I'm hopeful that the datetime64 dtype will enable scikits.timeseries
and pandas to consolidate much ofir the datetime / frequency code.
scikits.timeseries has a ton of great stuff for generating dates with
all the standard fixed frequencies.
More information about the NumPy-Discussion