add some stuff to improve date handling

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1278 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-10-06 07:28:30 +00:00
parent c64b796928
commit 811d752a12
2 changed files with 20 additions and 7 deletions

View File

@ -107,6 +107,11 @@
#define RFLAGS O_RDONLY
#define VERSION 7
/* hack alert the current file format does not support most of the
* new/improved account & transaction structures
*/
/** GLOBALS *********************************************************/
/* the default currency is used when importin old-style

View File

@ -25,6 +25,9 @@
#include <assert.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include "config.h"
@ -788,6 +791,15 @@ xaccTransCommitEdit (Transaction *trans)
return;
}
/* try to get the sorting order lined up according to
* when the user typed things in. */
if (0 == trans->date_entered.tv_sec) {
struct timeval tv;
gettimeofday (&tv, NULL);
trans->date_entered.tv_sec = tv.tv_sec;
trans->date_entered.tv_nsec = 1000 * tv.tv_usec;
}
/* Alternately the transaction may have only one split in
* it, in which case ... that's OK if and only if the split has no
* value (i.e. is only recording a price). Otherwise, a single
@ -1265,14 +1277,14 @@ xaccTransOrder (Transaction **ta, Transaction **tb)
db = (*tb)->num;
SAFE_STRCMP (da, db);
/* if dates differ, return */
DATE_CMP(ta,tb,date_entered);
/* otherwise, sort on description string */
da = (*ta)->description;
db = (*tb)->description;
SAFE_STRCMP (da, db);
/* if dates differ, return */
DATE_CMP(ta,tb,date_entered);
/* otherwise, sort on docref string */
da = (*ta)->docref;
db = (*tb)->docref;
@ -1364,10 +1376,6 @@ xaccTransSetDateSecs (Transaction *trans, time_t secs)
if (!trans) return;
CHECK_OPEN (trans);
/* hack alert -- for right now, keep the posted and the entered
* dates in sync. Later, we'll have to split these up. */
trans->date_entered.tv_sec = secs;
trans->date_posted.tv_sec = secs;
/* Because the date has changed, we need to make sure that each of the