diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2014-11-23 16:12:26 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2014-11-23 16:12:26 +0100 |
commit | 6211708a95a64728350ad8d0d3cc374388d49307 (patch) | |
tree | 1e72ad20142a186c50e8452565229bb7c06e2c8e | |
parent | b2db891c1971a933104471b72877c90dd71aca53 (diff) | |
download | mariadb-git-6211708a95a64728350ad8d0d3cc374388d49307.tar.gz |
- Fix a bug causing the day always printed as Sunday for date columns with
a date format specifying DDD or DDDD.
modified:
storage/connect/ha_connect.cc
storage/connect/value.cpp
-rw-r--r-- | storage/connect/ha_connect.cc | 1 | ||||
-rw-r--r-- | storage/connect/value.cpp | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 1453c418025..957c28abd28 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -1326,6 +1326,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf) datm.tm_mday= 12; datm.tm_mon= 11; datm.tm_year= 112; + mktime(&datm); // to get proper day name len= strftime(buf, 256, pdtp->OutFmt, &datm); } else len= 0; diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 81d00862703..11793a7b141 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -2484,8 +2484,10 @@ char *DTVAL::GetCharString(char *p) size_t n = 0; struct tm tm, *ptm= GetGmTime(&tm); - if (ptm) + if (ptm) { + mktime(ptm); // Populate tm_wday and tm_yday to get day name n = strftime(Sdate, Len + 1, Pdtp->OutFmt, ptm); + } // endif ptm if (!n) { *Sdate = '\0'; @@ -2511,6 +2513,8 @@ char *DTVAL::ShowValue(char *buf, int len) if (!Null) { size_t m, n = 0; struct tm tm, *ptm = GetGmTime(&tm); + + if (Len < len) { p = buf; @@ -2520,8 +2524,10 @@ char *DTVAL::ShowValue(char *buf, int len) m = Len + 1; } // endif Len - if (ptm) + if (ptm) { + mktime(ptm); // Populate tm_wday and tm_yday to get day name n = strftime(p, m, Pdtp->OutFmt, ptm); + } // endif ptm if (!n) { *p = '\0'; |