[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GT] Re: package Finance::GeniusTrader::DateTime::Day;
- To: devel
AT
geniustrader.org
- Subject: [GT] Re: package Finance::GeniusTrader::DateTime::Day;
- From: Chia-liang Kao <clkao
AT
clkao.org>
- Date: Wed, 18 Nov 2009 20:46:50 +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=H9Pc3BGEncnyZYb9m4BpkrNr7md7f9gqL+6MeQrMPHw=; b=OW+Q9zfEkDPkQkB5JyRdNGnD3xUW/b8MuIvYo6dmUnc+ECc3vw+ThIgPOGEMuDPzz9 6w/4ZUhbK8RcuJ82Y4zQPd/vMu0FxTNg4ZMP0A9fQwcqmNJK+n9RIMuraqUkuPGV3B7x F1TWkEZTyKDjO3DLU77XbRRBDJp3JaGl1BUo8=
- 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=Zl3Yujow7kiUs1DIE0dJlWUdJLAks3fPKj/WEanuROO3P2kqeMnKBYDOFbXec8xrDo waVJhSXT1yA/JZXNMe/6ZsFftubcu2A50hOyt5Ium2nXZY2KTfdir4gCsGg2ZFneh80E /xHx6DGDwCIBE5c2tMf+OgGNyEX1yhyNKJJ+4=
- In-reply-to: <200911181233.53826.josef-strobel
AT
web.de>
- Message-id: <cdd66f110911180446k6156262axeb6a1f22a68d8752@mail.gmail.com> (sfid-20091118_135741_584519_B78B448D)
- Reply-to: devel
AT
geniustrader.org
- Sender: chialiang
AT
gmail.com
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
>