I was putting my receipts in for the last half month or so recently
and noticed that I had to be careful to notice the year that the
receipts were in.  When putting in 12/23 or similar, I didn't get
December 23, 2006, but December 23, 2007.  I thought this should be
different, so I dove into the gnucash code and changed qof_scan_date
slightly to choose the last year for December if the current month is
January.  The patch is attached.

I am not sure if this code is called from many other places than the
register date cell, but some cursory cscope digging shows a lot of
places where this behavior would probably be useful (scheduled
transactions, etc) getting to qof_scan_date eventually.

I asked on #gnucash and it was suggested that I bring it here since
there may be some debate.

--
Michael Janssen --- Jamuraa --- [EMAIL PROTECTED] --- [EMAIL PROTECTED]
--- gnucash-2.0.2.newyeardates/lib/libqof/qof/gnc-date.c	2007-01-07 01:46:04.000000000 -0600
+++ gnucash-2.0.2/lib/libqof/qof/gnc-date.c	2006-10-08 12:14:40.000000000 -0500
@@ -736,7 +736,6 @@
    int iday, imonth, iyear;
    struct tm *now, utc;
    time_t secs;
-   int year_unspecified;
 
    if (!buff) return(FALSE);
 
@@ -777,7 +776,6 @@
    imonth = now->tm_mon+1;
    iyear = now->tm_year+1900;
 
-   year_unspecified = 1;
    /* get numeric values */
    switch (which_format)
    {
@@ -795,7 +793,6 @@
            iyear = thetime.tm_year + 1900;
            iday = thetime.tm_mday;
            imonth = thetime.tm_mon + 1;
-           year_unspecified = 0;
          } else if (second_field) {
            /* Hard. Two values parsed.  Figure out the ordering. */
            if (thetime.tm_year == -1) {
@@ -822,7 +819,6 @@
          iday = atoi(first_field);
          imonth = atoi(second_field);
          iyear = atoi(third_field);
-         year_unspecified = 0;
        } else if (second_field) {
          iday = atoi(first_field);
          imonth = atoi(second_field);
@@ -835,7 +831,6 @@
          iyear = atoi(first_field);
          imonth = atoi(second_field);
          iday = atoi(third_field);
-         year_unspecified = 0;
        } else if (second_field) {
          imonth = atoi(first_field);
          iday = atoi(second_field);
@@ -849,7 +844,6 @@
          imonth = atoi(first_field);
          iday = atoi(second_field);
          iyear = atoi(third_field);
-         year_unspecified = 0;
        } else if (second_field) {
          imonth = atoi(first_field);
          iday = atoi(second_field);
@@ -896,11 +890,6 @@
    if (iyear < 100)
      iyear += ((int) ((now->tm_year+1950-iyear)/100)) * 100;
 
-   /* If we entered say, December, and it's only January, we probably meant
-      last year. */
-   if (year_unspecified && now->tm_mon == 0 && imonth == 12)
-     iyear = iyear - 1;
-
    if (year) *year=iyear;
    if (month) *month=imonth;
    if (day) *day=iday;
_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to