[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GT] Re: Re: package Finance::GeniusTrader::DateTime::Day;
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
>