changes from rob browning

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1708 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1999-05-30 00:17:48 +00:00
parent 935d2436f1
commit ef9c6fbeff
2 changed files with 51 additions and 38 deletions

View File

@ -1510,7 +1510,7 @@ xaccTransSetDateEnteredSecs (Transaction *trans, time_t secs)
} }
void void
xaccTransSetDateTS (Transaction *trans, Timespec *ts) xaccTransSetDateTS (Transaction *trans, const Timespec *ts)
{ {
if (!trans) return; if (!trans) return;
CHECK_OPEN (trans); CHECK_OPEN (trans);
@ -1525,7 +1525,7 @@ xaccTransSetDateTS (Transaction *trans, Timespec *ts)
} }
void void
xaccTransSetDateEnteredTS (Transaction *trans, Timespec *ts) xaccTransSetDateEnteredTS (Transaction *trans, const Timespec *ts)
{ {
if (!trans) return; if (!trans) return;
CHECK_OPEN (trans); CHECK_OPEN (trans);
@ -1536,9 +1536,9 @@ xaccTransSetDateEnteredTS (Transaction *trans, Timespec *ts)
#define THIRTY_TWO_YEARS 0x3c30fc00LL #define THIRTY_TWO_YEARS 0x3c30fc00LL
void Timespec
xaccTransSetDate (Transaction *trans, int day, int mon, int year) gnc_dmy2timespec(int day, int month, int year) {
{ Timespec result;
struct tm date; struct tm date;
long long secs = 0; long long secs = 0;
long long era = 0; long long era = 0;
@ -1557,7 +1557,7 @@ xaccTransSetDate (Transaction *trans, int day, int mon, int year)
} }
date.tm_year = year; date.tm_year = year;
date.tm_mon = mon - 1; date.tm_mon = month - 1;
date.tm_mday = day; date.tm_mday = day;
date.tm_hour = 11; date.tm_hour = 11;
date.tm_min = 0; date.tm_min = 0;
@ -1568,7 +1568,17 @@ xaccTransSetDate (Transaction *trans, int day, int mon, int year)
secs += era * THIRTY_TWO_YEARS; secs += era * THIRTY_TWO_YEARS;
xaccTransSetDateSecsL (trans, secs); result.tv_sec = secs;
result.tv_nsec = 0;
return(result);
}
void
xaccTransSetDate (Transaction *trans, int day, int mon, int year) {
Timespec ts = gnc_dmy2timespec(day, mon, year);
xaccTransSetDateTS (trans, &ts);
} }
void void

View File

@ -140,6 +140,9 @@ void xaccTransBeginEdit (Transaction *, int defer);
void xaccTransCommitEdit (Transaction *); void xaccTransCommitEdit (Transaction *);
void xaccTransRollbackEdit (Transaction *); void xaccTransRollbackEdit (Transaction *);
/* Convert a day, month, and year to a Timespec */
Timespec gnc_dmy2timespec(int day, int month, int year);
/* /*
* The xaccTransSetDateSecs() method will modify the posted date * The xaccTransSetDateSecs() method will modify the posted date
* of the transaction. (Footnote: this shouldn't matter to a user, * of the transaction. (Footnote: this shouldn't matter to a user,
@ -161,10 +164,10 @@ void xaccTransRollbackEdit (Transaction *);
void xaccTransSetDate (Transaction *, int day, int mon, int year); void xaccTransSetDate (Transaction *, int day, int mon, int year);
void xaccTransSetDateSecs (Transaction *, time_t); void xaccTransSetDateSecs (Transaction *, time_t);
void xaccTransSetDateToday (Transaction *); void xaccTransSetDateToday (Transaction *);
void xaccTransSetDateTS (Transaction *, Timespec *); void xaccTransSetDateTS (Transaction *, const Timespec *);
void xaccTransSetDateEnteredSecs (Transaction *, time_t); void xaccTransSetDateEnteredSecs (Transaction *, time_t);
void xaccTransSetDateEnteredTS (Transaction *, Timespec *); void xaccTransSetDateEnteredTS (Transaction *, const Timespec *);
/* set the Num and Description fields ... */ /* set the Num and Description fields ... */