[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GT] SVN Commit r638 - branches/exp/GT



Author: thomas
Date: 2008-06-14 07:27:40 +0200 (Sat, 14 Jun 2008)
New Revision: 638

Modified:
   branches/exp/GT/Prices.pm
Log:
Apply 2007 format updates also to savetext, where that had been omitted.

Modified: branches/exp/GT/Prices.pm
===================================================================
--- branches/exp/GT/Prices.pm	2008-06-14 05:26:24 UTC (rev 637)
+++ branches/exp/GT/Prices.pm	2008-06-14 05:27:40 UTC (rev 638)
@@ -42,6 +42,8 @@
     my $type = shift;
     my $class = ref($type) || $type;
 
+    # NOTE: 'timeframe' is also an attribute, but is provided through
+    # accessor functions.
     my $self = { 'prices' => [], 'has_date' => '' };
     return bless $self, $class;
 }
@@ -403,7 +405,7 @@
     my ($self, $file, $mark, $date_format, %fields) = @_;
     open(FILE, '>', "$file") || die "Can't write in $file: $!\n";
     my ($open, $high, $low, $close, $volume, $date);
-    my ($year, $month, $day);
+    my ($year, $month, $day, $tm);
 
     $mark = $mark || "\t";
 
@@ -423,18 +425,26 @@
       $low = $line[$fields{'low'}];
       $close = $line[$fields{'close'}];
       $volume = $line[$fields{'volume'}];
-      $date = $line[$fields{'date'}];  # No obvious way how to divide date into mulitple fields
+      $date = $line[$fields{'date'}];
 
+      $date_format = 0 if $self->timeframe != $DAY;
+
       if ($date_format != 0) {
 		
-	if ($date_format eq 1) {
+	if ($date_format == 1) {
 	  ($year, $month, $day) = split(/-/, $date);
 	  $date = "$month/$day/$year"; 
 	}
-	if ($date_format eq 2) {
+	if ($date_format == 2) {
 	  ($year, $month, $day) = split(/-/, $date);
 	  $date = "$day/$month/$year"; 
 	}
+	if ($date_format == 3) {
+	  ($date, $tm) = split(/ /, $date);
+	  ($year, $month, $day) = split(/-/, $date);
+	  $date = "$day/$month/$year $tm"; 
+	}
+	
       }
 
       my @newline = ();
@@ -489,7 +499,6 @@
 	return undef;
 }
 
-
 =pod
 
 =back