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.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23044 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2013-06-09 21:32:06 +00:00
parent 581871813d
commit 697d228eb3
2 changed files with 27 additions and 3 deletions

View File

@ -1803,6 +1803,14 @@ xaccTransSetDatePostedSecs (Transaction *trans, time64 secs)
set_gains_date_dirty (trans);
}
void
xaccTransSetDatePostedSecsNormalized (Transaction *trans, time64 time)
{
GDate date;
gnc_gdate_set_time64(&date, time);
xaccTransSetDatePostedGDate(trans, date);
}
void
xaccTransSetDatePostedGDate (Transaction *trans, GDate date)
{

View File

@ -556,11 +556,27 @@ void xaccTransSetDate (Transaction *trans,
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,