Skip to content

Commit 6211708

Browse files
committed
- 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
1 parent b2db891 commit 6211708

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

storage/connect/ha_connect.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
13261326
datm.tm_mday= 12;
13271327
datm.tm_mon= 11;
13281328
datm.tm_year= 112;
1329+
mktime(&datm); // to get proper day name
13291330
len= strftime(buf, 256, pdtp->OutFmt, &datm);
13301331
} else
13311332
len= 0;

storage/connect/value.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,8 +2484,10 @@ char *DTVAL::GetCharString(char *p)
24842484
size_t n = 0;
24852485
struct tm tm, *ptm= GetGmTime(&tm);
24862486

2487-
if (ptm)
2487+
if (ptm) {
2488+
mktime(ptm); // Populate tm_wday and tm_yday to get day name
24882489
n = strftime(Sdate, Len + 1, Pdtp->OutFmt, ptm);
2490+
} // endif ptm
24892491

24902492
if (!n) {
24912493
*Sdate = '\0';
@@ -2511,6 +2513,8 @@ char *DTVAL::ShowValue(char *buf, int len)
25112513
if (!Null) {
25122514
size_t m, n = 0;
25132515
struct tm tm, *ptm = GetGmTime(&tm);
2516+
2517+
25142518

25152519
if (Len < len) {
25162520
p = buf;
@@ -2520,8 +2524,10 @@ char *DTVAL::ShowValue(char *buf, int len)
25202524
m = Len + 1;
25212525
} // endif Len
25222526

2523-
if (ptm)
2527+
if (ptm) {
2528+
mktime(ptm); // Populate tm_wday and tm_yday to get day name
25242529
n = strftime(p, m, Pdtp->OutFmt, ptm);
2530+
} // endif ptm
25252531

25262532
if (!n) {
25272533
*p = '\0';

0 commit comments

Comments
 (0)