<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -30,6 +30,7 @@ libledger_util_la_LDFLAGS  = -release $(VERSION).0
 libledger_math_la_SOURCES =			\
 	src/value.cc				\
 	src/balance.cc				\
+	src/quotes.cc				\
 	src/pool.cc				\
 	src/annotate.cc				\
 	src/commodity.cc			\
@@ -67,7 +68,6 @@ libledger_data_la_CPPFLAGS = $(lib_cppflags)
 libledger_data_la_LDFLAGS  = -release $(VERSION).0
 
 libledger_report_la_SOURCES  =			\
-	src/quotes.cc				\
 	src/stats.cc				\
 	src/generate.cc				\
 	src/derive.cc				\
@@ -98,6 +98,7 @@ pkginclude_HEADERS =				\
 	src/commodity.h				\
 	src/annotate.h				\
 	src/pool.h				\
+	src/quotes.h				\
 	src/balance.h				\
 	src/value.h				\
 						\
@@ -130,7 +131,6 @@ pkginclude_HEADERS =				\
 	src/stats.h				\
 	src/output.h				\
 	src/emacs.h				\
-	src/quotes.h				\
 						\
 	src/global.h				\
 						\</diff>
      <filename>Makefile.am</filename>
    </modified>
    <modified>
      <diff>@@ -390,8 +390,8 @@ void related_posts::flush()
 
 void changed_value_posts::flush()
 {
-  if (last_post &amp;&amp; last_post-&gt;date() &lt;= report.terminus) {
-    output_revaluation(last_post, report.terminus);
+  if (last_post &amp;&amp; last_post-&gt;date() &lt;= report.terminus.date()) {
+    output_revaluation(last_post, report.terminus.date());
     last_post = NULL;
   }
   item_handler&lt;post_t&gt;::flush();</diff>
      <filename>src/filters.cc</filename>
    </modified>
    <modified>
      <diff>@@ -507,8 +507,8 @@ void global_scope_t::normalize_report_options(const string&amp; verb)
   // settings that may be there.
   if (rep.HANDLED(exchange_) &amp;&amp;
       rep.HANDLER(exchange_).str().find('=') != string::npos) {
-    value_t(0L).exchange_commodities(rep.HANDLER(exchange_).str(),
-				     true, datetime_t(rep.terminus));
+    value_t(0L).exchange_commodities(rep.HANDLER(exchange_).str(), true,
+				     rep.terminus);
   }
 
   long cols = 0;</diff>
      <filename>src/global.cc</filename>
    </modified>
    <modified>
      <diff>@@ -75,7 +75,13 @@ void interactive_t::verify_arguments() const
       break;
     case 'd':
       label = _(&quot;a date&quot;);
-      wrong_arg = ! next_arg-&gt;is_date();
+      wrong_arg = (! next_arg-&gt;is_date() &amp;&amp;
+		   ! next_arg-&gt;is_datetime());
+      break;
+    case 't':
+      label = _(&quot;a date/time&quot;);
+      wrong_arg = (! next_arg-&gt;is_date() &amp;&amp;
+		   ! next_arg-&gt;is_datetime());
       break;
     case 'i':
     case 'l':
@@ -106,11 +112,6 @@ void interactive_t::verify_arguments() const
       label = _(&quot;a string&quot;);
       wrong_arg = ! next_arg-&gt;is_string();
       break;
-    case 't':
-      label = _(&quot;a date or time&quot;);
-      wrong_arg = (! next_arg-&gt;is_date() &amp;&amp;
-		   ! next_arg-&gt;is_datetime());
-      break;
     case 'v':
       label = _(&quot;any value&quot;);
       wrong_arg = false;</diff>
      <filename>src/interactive.cc</filename>
    </modified>
    <modified>
      <diff>@@ -35,12 +35,14 @@
 #include &quot;commodity.h&quot;
 #include &quot;annotate.h&quot;
 #include &quot;pool.h&quot;
+#include &quot;quotes.h&quot;
 
 namespace ledger {
 
 commodity_pool_t::commodity_pool_t()
   : default_commodity(NULL), keep_base(false),
-    quote_leeway(86400), get_quotes(false)
+    quote_leeway(86400), get_quotes(false),
+    get_commodity_quote(commodity_quote_from_script)
 {
   TRACE_CTOR(commodity_pool_t, &quot;&quot;);
   null_commodity = create(&quot;&quot;);
@@ -311,8 +313,11 @@ optional&lt;price_point_t&gt; commodity_pool_t::parse_price_directive(char * line)
   point.price.parse(symbol_and_price);
   VERIFY(point.price.valid());
 
+  DEBUG(&quot;commodity.download&quot;, &quot;Looking up symbol: &quot; &lt;&lt; symbol);
   if (commodity_t * commodity =
       amount_t::current_pool-&gt;find_or_create(symbol)) {
+    DEBUG(&quot;commodity.download&quot;, &quot;Adding price for &quot; &lt;&lt; symbol &lt;&lt; &quot;: &quot;
+	  &lt;&lt; point.when &lt;&lt; &quot; &quot; &lt;&lt; point.price);
     commodity-&gt;add_price(point.when, point.price, true);
     commodity-&gt;add_flags(COMMODITY_KNOWN);
     return point;</diff>
      <filename>src/pool.cc</filename>
    </modified>
    <modified>
      <diff>@@ -86,10 +86,9 @@ public:
   long		  quote_leeway;     // --leeway=
   bool		  get_quotes;       // --download
 
-public:
   function&lt;optional&lt;price_point_t&gt;
-	   (const commodity_t&amp;            commodity,
-	    const optional&lt;commodity_t&amp;&gt;&amp; in_terms_of)&gt; get_commodity_quote;
+	   (commodity_t&amp; commodity, const optional&lt;commodity_t&amp;&gt;&amp; in_terms_of)&gt;
+      get_commodity_quote;
 
   explicit commodity_pool_t();
 </diff>
      <filename>src/pool.h</filename>
    </modified>
    <modified>
      <diff>@@ -94,10 +94,17 @@ commodity_quote_from_script(commodity_t&amp; commodity,
       return point;
     }
   } else {
-    throw_(std::runtime_error,
-	   _(&quot;Failed to download price for '%1' (command: \&quot;getquote %2 %3\&quot;)&quot;)
-	   &lt;&lt; commodity.symbol() &lt;&lt; commodity.symbol()
-	   &lt;&lt; (exchange_commodity ? exchange_commodity-&gt;symbol() : &quot;''&quot;));
+    DEBUG(&quot;commodity.download&quot;,
+	  &quot;Failed to download price for '&quot; &lt;&lt; commodity.symbol() &lt;&lt;
+	  &quot;' (command: \&quot;getquote &quot; &lt;&lt; commodity.symbol() &lt;&lt;
+	  &quot; &quot; &lt;&lt; (exchange_commodity ?
+		  exchange_commodity-&gt;symbol() : &quot;''&quot;) &lt;&lt; &quot;\&quot;)&quot;);
+
+    // Don't try to download this commodity again.
+
+    // jww (2009-06-24): This flag should be removed in order to try again
+    // when using a GUI.
+    commodity.add_flags(COMMODITY_NOMARKET);
   }
   return none;
 }</diff>
      <filename>src/quotes.cc</filename>
    </modified>
    <modified>
      <diff>@@ -49,7 +49,8 @@
 namespace ledger {
 
 optional&lt;price_point_t&gt;
-commodity_quote_from_script(const optional&lt;commodity_t&amp;&gt;&amp; exchange_commodity);
+commodity_quote_from_script(commodity_t&amp; commodity,
+			    const optional&lt;commodity_t&amp;&gt;&amp; exchange_commodity);
 
 } // namespace ledger
 </diff>
      <filename>src/quotes.h</filename>
    </modified>
    <modified>
      <diff>@@ -259,9 +259,11 @@ value_t report_t::fn_join(call_scope_t&amp; args)
   return string_value(out.str());
 }
 
-value_t report_t::fn_format_date(call_scope_t&amp; args)
+value_t report_t::fn_format_date(call_scope_t&amp; scope)
 {
-  return string_value(format_date(args[0].to_date(), args[1].to_string()));
+  interactive_t args(scope, &quot;ds&quot;);
+  return string_value(format_date(args.get&lt;date_t&gt;(0),
+				  args.get&lt;string&gt;(1)));
 }
 
 value_t report_t::fn_ansify_if(call_scope_t&amp; scope)
@@ -752,7 +754,7 @@ expr_t::ptr_op_t report_t::lookup(const string&amp; name)
     else if (is_eq(p, &quot;display_total&quot;))
       return MAKE_FUNCTOR(report_t::fn_display_total);
     else if (is_eq(p, &quot;date&quot;))
-      return MAKE_FUNCTOR(report_t::fn_today);
+      return MAKE_FUNCTOR(report_t::fn_now);
     break;
 
   case 'f':
@@ -789,10 +791,8 @@ expr_t::ptr_op_t report_t::lookup(const string&amp; name)
   case 'n':
     if (is_eq(p, &quot;null&quot;))
       return WRAP_FUNCTOR(fn_null);
-#if 0
     else if (is_eq(p, &quot;now&quot;))
       return MAKE_FUNCTOR(report_t::fn_now);
-#endif
     break;
 
   case 'o':</diff>
      <filename>src/report.cc</filename>
    </modified>
    <modified>
      <diff>@@ -121,11 +121,11 @@ public:
 #define BUDGET_BUDGETED   0x01
 #define BUDGET_UNBUDGETED 0x02
 
-  date_t        terminus;
+  datetime_t    terminus;
   uint_least8_t budget_flags;
 
   explicit report_t(session_t&amp; _session)
-    : session(_session), terminus(CURRENT_DATE()),
+    : session(_session), terminus(CURRENT_TIME()),
       budget_flags(BUDGET_NO_BUDGET) {}
 
   virtual ~report_t() {
@@ -159,13 +159,11 @@ public:
   value_t fn_ansify_if(call_scope_t&amp; scope);
   value_t fn_percent(call_scope_t&amp; scope);
 
-#if 0
   value_t fn_now(call_scope_t&amp;) {
-    return CURRENT_TIME();
+    return terminus;
   }
-#endif
   value_t fn_today(call_scope_t&amp;) {
-    return terminus;
+    return terminus.date();
   }
 
   value_t fn_options(call_scope_t&amp;) {
@@ -484,7 +482,7 @@ public:
 	&quot;date&lt;[&quot; + to_iso_extended_string(*interval.start) + &quot;]&quot;;
       parent-&gt;HANDLER(limit_).on(string(&quot;--end&quot;), predicate);
 
-      parent-&gt;terminus = *interval.start;
+      parent-&gt;terminus = datetime_t(*interval.start);
     });
 
   OPTION(report_t, equity);</diff>
      <filename>src/report.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-bal --end 2008/12/31 -JV bal Equities
+bal --end 2008/12/31 -JV Equities
 &lt;&lt;&lt;
 2008/01/01 * Purchase Apple shares
        Equities        1000 AAPL @ $2</diff>
      <filename>test/regress/647D5DB9.test</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1fad2ec7c135ebe87bb34838f21adaac720dda03</id>
    </parent>
  </parents>
  <author>
    <name>John Wiegley</name>
    <email>johnw@newartisans.com</email>
  </author>
  <url>http://github.com/jwiegley/ledger/commit/4574c30fcfd3b03bab9a368a6ff2928af7e11e28</url>
  <id>4574c30fcfd3b03bab9a368a6ff2928af7e11e28</id>
  <committed-date>2009-06-26T08:52:41-07:00</committed-date>
  <authored-date>2009-06-26T08:52:41-07:00</authored-date>
  <message>The --download option is now fully restored</message>
  <tree>31112a34e89d39a51d6ed6f83e13978b69d97aa9</tree>
  <committer>
    <name>John Wiegley</name>
    <email>johnw@newartisans.com</email>
  </committer>
</commit>
