mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-25 18:30:23 -06:00
Add accessor/setter for the date of a GncEntry as a GDate.
This is much more suitable to avoid any ambiguities due to differently chosen time-of-day in various parts of the code. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21560 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
bbb529263b
commit
6a0f3b5a57
@ -445,6 +445,19 @@ void gncEntrySetDate (GncEntry *entry, Timespec date)
|
||||
}
|
||||
}
|
||||
|
||||
void gncEntrySetDateGDate (GncEntry *entry, const GDate* date)
|
||||
{
|
||||
if (!entry || !date || !g_date_valid(date))
|
||||
return;
|
||||
|
||||
/* Watch out: Here we are deviating from the initial convention that a
|
||||
GDate always converts to the start time of the day. Instead, the GDate is
|
||||
converted to "noon" on the respective date. This is not nice, but this
|
||||
convention was used for the Timespec of GncEntry all the time, so we better
|
||||
stick to it.*/
|
||||
gncEntrySetDate(entry, timespecCanonicalDayTime(gdate_to_timespec(*date)));
|
||||
}
|
||||
|
||||
void gncEntrySetDateEntered (GncEntry *entry, Timespec date)
|
||||
{
|
||||
if (!entry) return;
|
||||
@ -804,6 +817,11 @@ Timespec gncEntryGetDate (const GncEntry *entry)
|
||||
return entry->date;
|
||||
}
|
||||
|
||||
GDate gncEntryGetDateGDate(const GncEntry *entry)
|
||||
{
|
||||
return timespec_to_gdate(gncEntryGetDate(entry));
|
||||
}
|
||||
|
||||
Timespec gncEntryGetDateEntered (const GncEntry *entry)
|
||||
{
|
||||
Timespec ts;
|
||||
|
@ -96,6 +96,11 @@ void gncEntryDestroy (GncEntry *entry);
|
||||
|
||||
/** @name Generic (shared) data
|
||||
@{ */
|
||||
/** Set the date of this entry */
|
||||
void gncEntrySetDateGDate (GncEntry *entry, const GDate* date);
|
||||
/** DEPRECATED - use gncEntrySetDateGDate() instead! (Because the time-of-day
|
||||
is a misleading extra information. We are only dealing with the day
|
||||
information! */
|
||||
void gncEntrySetDate (GncEntry *entry, Timespec date);
|
||||
void gncEntrySetDateEntered (GncEntry *entry, Timespec date);
|
||||
void gncEntrySetDescription (GncEntry *entry, const char *desc);
|
||||
@ -137,6 +142,11 @@ void gncEntrySetBillPayment (GncEntry *entry, GncEntryPaymentType type);
|
||||
/* GET FUNCTIONS */
|
||||
/** @name Generic (shared) data
|
||||
@{ */
|
||||
/** Returns the day of this entry */
|
||||
GDate gncEntryGetDateGDate (const GncEntry *entry);
|
||||
/** DEPRECATED - use gncEntryGetDateGDate() instead! (Because the time-of-day
|
||||
is a misleading extra information. We are only dealing with the day
|
||||
information! */
|
||||
Timespec gncEntryGetDate (const GncEntry *entry);
|
||||
Timespec gncEntryGetDateEntered (const GncEntry *entry);
|
||||
const char * gncEntryGetDescription (const GncEntry *entry);
|
||||
|
Loading…
Reference in New Issue
Block a user