[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GT] Re: Re: Re: package Finance::GeniusTrader::DateTime::Day;
- To: devel
AT
geniustrader.org
- Subject: [GT] Re: Re: Re: package Finance::GeniusTrader::DateTime::Day;
- From: Chia-liang Kao <clkao
AT
clkao.org>
- Date: Wed, 18 Nov 2009 21:03:24 +0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=dBAWAU+FqOckX2HuTGu7L0MMobHKtStWcxYvrhjuOWY=; b=O+uyJdx+cwPdAPyf9Cz/VshJbfmdI1pGxZsXr87WIGX1XnMUw5t7wm0/ihzqEt9mPQ jgEpcItj/F4QhDYO+eF386CvGuuzH93y35Kb/jSI5iI8f3+mNUFN3yIrKaWz6HAm7WWX tLHuu6zsHWmUCxacHQV43+jPt6yyXZ1cz5fyg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=UX+8SehfAZ67lAYDG9BPgBY9hLhyvVvg2M1EMDlGS6Zpsj0T8ypAj7/oaxaQB7gger UvVI+2LzAh3xPnwBG1tMM6t2prpzZh+j1BcaTmfR1DyDuiSFJxPTIMVfZzG1jEUzsaBj avzHb97V/arKVVIsfQMO5dN/AGkRSteRjuQmI=
- In-reply-to: <200911181358.07272.josef-strobel
AT
web.de>
- Message-id: <cdd66f110911180503mfe63065j6180c0a9b75ab7ac@mail.gmail.com> (sfid-20091118_141414_699810_2EBDD5D8)
- Reply-to: devel
AT
geniustrader.org
- Sender: chialiang
AT
gmail.com
from Time::Local:
Negative Epoch Values
Negative epoch (time_t) values are not officially supported by the
POSIX standards, so this module's tests do not test them. On some
systems, they are known not to work. These include MacOS (pre-OSX) and
Win32.
On systems which do support negative epoch values, this module should
be able to cope with dates before the start of the epoch, down the
minimum value of time_t for the system.
2009/11/18 Josef Strobel <josef-strobel
AT
web.de>:
> Hi,
>
> Its actually a 32bit integer problem. Epoch started 1970-01-01 so problems wit 32bit integers are
> before 1901-12-13 and after 2038-01-19, but there shouldn't be problems in this time frame.
>
> http://en.wikipedia.org/wiki/Unix_time
> The standard Unix time_t (data type representing a point in time) is a signed integer data type,
> traditionally of 32 bits (but see below), directly encoding the Unix time number as described in the
> preceding section. Being 32 bits (of which one bit is the sign bit) means that it covers a range of
> about 136 years in total. The minimum representable time is 1901-12-13, and the maximum
> representable time is 2038-01-19. At 03:14:07 UTC 2038-01-19 this representation overflows. This
> milestone is anticipated with a mixture of amusement and dread;
>
>
> Am Mittwoch 18 November 2009 schrieb Chia-liang Kao:
>> Hi Josef,
>>
>> 1960 is before epoch, and time::local wouldn't be able to support
>> that. neither would it support years > 2038. ÂWe'll need to migrate to
>> something like Time::y2038 or DateTime.
>>
>> 2009/11/18 Josef Strobel <josef-strobel
AT
web.de>:
>> > Hi all,
>> >
>> > I tried to load a time series where the start date is before 1960-12-31,
>> > but I always get the following error:
>> >
>> > my time series:
>> >
>> > 1960-01-25,56.78,56.78,56.78,56.78,2790000,56.78
>> > 1960-01-22,57.38,57.38,57.38,57.38,2690000,57.38
>> > 1960-01-21,57.21,57.21,57.21,57.21,2700000,57.21
>> > 1960-01-20,57.07,57.07,57.07,57.07,2720000,57.07
>> > 1960-01-19,57.27,57.27,57.27,57.27,3100000,57.27
>> > 1960-01-18,57.89,57.89,57.89,57.89,3020000,57.89
>> > 1960-01-15,58.38,58.38,58.38,58.38,3400000,58.38
>> > 1960-01-14,58.40,58.40,58.40,58.40,3560000,58.40
>> > 1960-01-13,58.08,58.08,58.08,58.08,3470000,58.08
>> > 1960-01-12,58.41,58.41,58.41,58.41,3760000,58.41
>> > 1960-01-11,58.77,58.77,58.77,58.77,3470000,58.77
>> > 1960-01-08,59.50,59.50,59.50,59.50,3290000,59.50
>> > 1960-01-07,59.69,59.69,59.69,59.69,3310000,59.69
>> > 1960-01-06,60.13,60.13,60.13,60.13,3730000,60.13
>> > 1960-01-05,60.39,60.39,60.39,60.39,3710000,60.39
>> > 1960-01-04,59.91,59.91,59.91,59.91,3990000,59.91
>> > 1959-12-31,59.89,59.89,59.89,59.89,3810000,59.89
>> >
>> >
>> > $HOME/eclipse-workspace/geniustrader/script/graphic.pl --file
>> > $HOME/eclipse-
>> > workspace/geniustrader/own-scripts/graphic/graphic_examples.conf ^GSPC >
>> > foobar.png Day too big - 32871 > 24853
>> > Cannot handle date (0, 0, 0, 31, 11, 2059) at
>> > /home/josef/cpan/Finance/GeniusTrader/DateTime/Day.pm line 24
>> >
>> >
>> > When I remove the last line in my time series it worked, so I looked in
>> > Finance::GeniusTrader::DateTime::Day and took a look to the function
>> > timelocal from Time::Local.
>> >
>> > I wrote a small script time-date-test.pl. It should test all dates from
>> > 1900-01-01 to 2039-01-01, but it fails from 1938-01-17.
>> >
>> > #!/usr/bin/perl
>> >
>> > use warnings;
>> > use strict;
>> > use Time::Local;
>> > use Date::Calc qw( Delta_Days Add_Delta_Days );
>> >
>> > # sub from package Finance::GeniusTrader::DateTime::Day;
>> > sub map_date_to_time {
>> > Â Âmy ($date) = @_;
>> > Â Âmy ($y, $m, $d) = split /-/, $date;
>> > Â Â Â Â Â Â Â Â($d) = split / /, $d;
>> > Â Â Â Â Â Â Â Âprint $d . "," . ($m - 1) . "," . ($y - 1900) . "\n";
>> > Â Âprint timelocal(0, 0, 0, $d, $m - 1, $y - 1900) . "\n";
>> > }
>> >
>> >
>> >
>> > my @start = (1900,1,1);
>> > my @stop Â= (2039,01,01);
>> >
>> > my $j = Delta_Days(@start,@stop);
>> >
>> > for (my $i = 0; $i <= $j; $i++ )
>> > {
>> > Â Âmy ($year,$month,$day) = Add_Delta_Days(@start,$i);
>> > Â Âprintf("%4d/%02d/%02d\n", $year,$month,$day);
>> > Â Â&map_date_to_time("$year-$month-$day");
>> > }
>> >
>> >
>> > So what is timelocal doing?
>> >
>> >
>> > Best regards
>> > Josef
>>
>