r18575 - gnucash/trunk/src/quotes - Bug #607185: Add f-q workaround for missing date.

Christian Stimming cstim at code.gnucash.org
Sun Jan 17 16:26:49 EST 2010


Author: cstim
Date: 2010-01-17 16:26:48 -0500 (Sun, 17 Jan 2010)
New Revision: 18575
Trac: http://svn.gnucash.org/trac/changeset/18575

Modified:
   gnucash/trunk/src/quotes/gnc-fq-helper.in
Log:
Bug #607185: Add f-q workaround for missing date.

Patch by "meo":

If for whatever reason finance-quote is unable to get a date for a quote or to
convert it to the standardized form, gnucash is unable to use the otherwise
correct quote. With web pages being updated definitively more frequently than
finance-quote, this is quite a nuisance.
Up to now, gnc-fq-helper emits an error message + the quote, a combination
gnucash is unable to process. This patch presents a workaround.

I would prefer using the current date + 12 hours rather than current date +
time, but this is open for discussion.

Modified: gnucash/trunk/src/quotes/gnc-fq-helper.in
===================================================================
--- gnucash/trunk/src/quotes/gnc-fq-helper.in	2010-01-16 20:38:02 UTC (rev 18574)
+++ gnucash/trunk/src/quotes/gnc-fq-helper.in	2010-01-17 21:26:48 UTC (rev 18575)
@@ -219,6 +219,12 @@
   $parsestr = ParseDateString($parsestr);
 
   my $result = UnixDate($parsestr, "\"%Y-%m-%d %H:%M:%S\"");
+  if(!$result) {
+    # Fix date handling for quotes with no date: assume local date
+    (my $second,my $minute,my $hour,my $dayofmonth,my $month,my $year,my $dayofweek,my $dayofyear,my $daylightsaving) = localtime();
+#    $result = "\"".sprintf("%04d-%02d-%02d%02d:%02d:%02d",($year+1900),++$month,$dayOfMonth,$hour,$minute,$second)."\"";
+    $result = "\"" . sprintf("%04d-%02d-%02d", ($year+1900), ++$month, $dayofmonth) . " 12:00:00\"";
+  }
   if($result !~ /^\"\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\"$/) {
     $result = "failed-conversion";
   }



More information about the gnucash-changes mailing list