Changeset: 9fc902729295 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9fc902729295
Modified Files:
        monetdb5/modules/atoms/mtime.c
Branch: Jul2017
Log Message:

re-init the tm structure using mktime (solves bug 6467).


diffs (27 lines):

diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -3463,6 +3463,7 @@ MTIMEdate_to_str(str *s, const date *d, 
        fromdate(*d, &t.tm_mday, &mon, &year);
        t.tm_mon = mon - 1;
        t.tm_year = year - 1900;
+       (void)mktime(&t); /* corrects the tm_wday etc */
        if ((sz = strftime(buf, BUFSIZ, *format, &t)) == 0)
                throw(MAL, "mtime.date_to_str", "failed to convert date to 
string using format '%s'\n", *format);
        *s = GDKmalloc(sz + 1);
@@ -3507,6 +3508,7 @@ MTIMEtime_to_str(str *s, const daytime *
        memset(&t, 0, sizeof(struct tm));
        fromtime(*d, &t.tm_hour, &t.tm_min, &t.tm_sec, &msec);
        (void)msec;
+       (void)mktime(&t); /* corrects the tm_wday etc */
        if ((sz = strftime(buf, BUFSIZ, *format, &t)) == 0)
                throw(MAL, "mtime.time_to_str", "failed to convert time to 
string using format '%s'\n", *format);
        *s = GDKmalloc(sz + 1);
@@ -3554,6 +3556,7 @@ MTIMEtimestamp_to_str(str *s, const time
        t.tm_mon = mon - 1;
        t.tm_year = year - 1900;
        fromtime(ts->msecs, &t.tm_hour, &t.tm_min, &t.tm_sec, &msec);
+       (void)mktime(&t); /* corrects the tm_wday etc */
        (void)msec;
        if ((sz = strftime(buf, BUFSIZ, *format, &t)) == 0)
                throw(MAL, "mtime.timestamp_to_str", "failed to convert 
timestampt to string using format '%s'\n", *format);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to