Skip to content

Commit

Permalink
Fix date format.
Browse files Browse the repository at this point in the history
  • Loading branch information
twose committed Mar 12, 2019
1 parent 6a51d73 commit 853f4c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/core/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void swLog_put(int level, char *content, size_t length)
t = time(NULL);
p = localtime(&t);
size_t l_data_str = sw_snprintf(
date_str, SW_LOG_DATE_STRLEN, "%d-%02d-%02d %02d:%02d:%02d",
date_str, SW_LOG_DATE_STRLEN, "%d-%.2d-%.2d %.2d:%.2d:%.2d",
p->tm_year + 1900, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec
);
#if 0
Expand Down
8 changes: 4 additions & 4 deletions swoole_mysql_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ static int mysql_decode_datetime(char *buf, char *result)
s = *(uint8_t *) (buf + 7);
}
}
snprintf(result, DATETIME_MAX_SIZE, "%04d-%02d-%02d %02d:%02d:%02d", y, M, d, h, m, s);
snprintf(result, DATETIME_MAX_SIZE, "%.4u-%.2u-%.2u %.2u:%.2u:%.2u", y, M, d, h, m, s);

swTraceLog(SW_TRACE_MYSQL_CLIENT, "n=%d", n);

Expand All @@ -825,7 +825,7 @@ static int mysql_decode_time(char *buf, char *result)
s = *(uint8_t *) (buf + 8);
}

snprintf(result, DATETIME_MAX_SIZE, "%02d:%02d:%02d", h, m, s);
snprintf(result, DATETIME_MAX_SIZE, "%.2u:%.2u:%.2u", h, m, s);

swTraceLog(SW_TRACE_MYSQL_CLIENT, "n=%d", n);

Expand All @@ -844,7 +844,7 @@ static int mysql_decode_date(char *buf, char *result)
M = *(uint8_t *) (buf + 3);
d = *(uint8_t *) (buf + 4);
}
snprintf(result, DATETIME_MAX_SIZE, "%04d-%02d-%02d", y, M, d);
snprintf(result, DATETIME_MAX_SIZE, "%.4u-%.2u-%.2u", y, M, d);

swTraceLog(SW_TRACE_MYSQL_CLIENT, "n=%d", n);

Expand All @@ -854,7 +854,7 @@ static int mysql_decode_date(char *buf, char *result)
static void mysql_decode_year(char *buf, char *result)
{
uint16_t y = *(uint16_t *) (buf);
snprintf(result, DATETIME_MAX_SIZE, "%04d", y);
snprintf(result, DATETIME_MAX_SIZE, "%.4u", y);
}

static ssize_t mysql_decode_row_prepare(mysql_client *client, char *buf, uint32_t packet_length, size_t n_buf)
Expand Down

0 comments on commit 853f4c9

Please sign in to comment.