r23044 - gnucash/trunk/src/engine - Introduce transaction setter xaccTransSetDatePostedSecsNormalized() that ignores the time-of-day part.

Christian Stimming cstim at code.gnucash.org
Sun Jun 9 17:32:08 EDT 2013


Author: cstim
Date: 2013-06-09 17:32:06 -0400 (Sun, 09 Jun 2013)
New Revision: 23044
Trac: http://svn.gnucash.org/trac/changeset/23044

Modified:
   gnucash/trunk/src/engine/Transaction.c
   gnucash/trunk/src/engine/Transaction.h
Log:
Introduce transaction setter xaccTransSetDatePostedSecsNormalized() that ignores the time-of-day part.

We've struggled with the time-of-day part of the PostedDate for long
enough. The PostedDate field is just not meaningful with anything else
but a plain date, and no time-of-day at all. Hence, the correct setter
function for this particular field must ignore the time-of-day. Consequently,
a GDate should be used here anyway, but in many places the time64 is more
convenient. The new function will now redirect that time64 to the GDate
setter function to make sure we will now map everything to one single date.

Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c	2013-06-09 21:31:51 UTC (rev 23043)
+++ gnucash/trunk/src/engine/Transaction.c	2013-06-09 21:32:06 UTC (rev 23044)
@@ -1804,6 +1804,14 @@
 }
 
 void
+xaccTransSetDatePostedSecsNormalized (Transaction *trans, time64 time)
+{
+    GDate date;
+    gnc_gdate_set_time64(&date, time);
+    xaccTransSetDatePostedGDate(trans, date);
+}
+
+void
 xaccTransSetDatePostedGDate (Transaction *trans, GDate date)
 {
     KvpValue* kvp_value;

Modified: gnucash/trunk/src/engine/Transaction.h
===================================================================
--- gnucash/trunk/src/engine/Transaction.h	2013-06-09 21:31:51 UTC (rev 23043)
+++ gnucash/trunk/src/engine/Transaction.h	2013-06-09 21:32:06 UTC (rev 23044)
@@ -556,11 +556,27 @@
 void xaccTransSetDatePostedGDate (Transaction *trans, GDate date);
 
 /** The xaccTransSetDatePostedSecs() method will modify the <i>posted</i>
-    date of the transaction, specified by a time64 (see ctime(3)). The
-    posted date is the date when this transaction was posted at the
-    bank. */
+ *  date of the transaction, specified by a time64 (see ctime(3)). The
+ *  posted date is the date when this transaction was posted at the
+ *  bank.
+ *
+ * Please do not use this function, as the extra time-of-day part messes up a
+ * lot of places. Rather, please use xaccTransSetDatePostedGDate() or
+ * xaccTransSetDatePostedSecsNormalized().
+ */
 void          xaccTransSetDatePostedSecs (Transaction *trans, time64 time);
 
+/** This function sets the <i>posted</i> date of the transaction, specified by
+ * a time64 (see ctime(3)). Contrary to xaccTransSetDatePostedSecs(), the time
+ * will be normalized to only the date part, and the time-of-day will be
+ * ignored. The resulting date is the same as if it had been set as a GDate
+ * through xaccTransSetDatePostedGDate().
+ *
+ * Please prefer this function over xaccTransSetDatePostedSecs().
+ *
+ * The posted date is the date when this transaction was posted at the bank. */
+void          xaccTransSetDatePostedSecsNormalized (Transaction *trans, time64 time);
+
 /**  The xaccTransSetDatePostedTS() method does the same thing as
      xaccTransSetDatePostedSecs(), but takes a struct timespec64. */
 void          xaccTransSetDatePostedTS (Transaction *trans,



More information about the gnucash-changes mailing list