Aug 9, 2013, 7:55 AM
Post #3 of 4
Thank you for the reply
Re: [hwnd] Sortable date conversions
[In reply to]
Iím working on a program to do stock market analysis. A typical link would be:
Thank you for the pointer to Time::Piece. Unless there is a better answer, the following code does work:
my $testDate = "Jun 7, 2013";
my $sortableTime = Time::Piece->strptime($testDate, "%b %d, %Y")->strftime("%Y.%m.%d");
It returns ď2013.06.07Ē which can then be used as the hash key with the adjusted close price, returned to the caller, and the hash can then be worked with in date order using a sorted key.
The data obtained from yahoo comes back in reverse time order, newest to oldest. When computing things like moving average, the data has to be looked at in standard time order, oldest to newest. Creating a hash in the called method, then sorting it in the calling program takes care of that.
Again, thanks for the reply.
If someone has a more "Perl-like" way for an old C C++ programmer to code things, I'd still like to here from you!