Skip to content

Commit

Permalink
- Fix a bug causing the day always printed as Sunday for date columns…
Browse files Browse the repository at this point in the history
… with

  a date format specifying DDD or DDDD.
modified:
  storage/connect/ha_connect.cc
  storage/connect/value.cpp
  • Loading branch information
Buggynours committed Nov 23, 2014
1 parent b2db891 commit 6211708
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions storage/connect/ha_connect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions storage/connect/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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';
Expand Down

0 comments on commit 6211708

Please sign in to comment.