mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
fix: 当 mysql 数据库日期类型(timestamp, datetime)的字段,数据值没有 "时间部分(时分秒)" 时,比如 "2019-01-01" (#1879)
数据的长度是4(年2,月1, 日1), 而不是预期的7(年2,月1, 日1, 时1, 分1, 秒1)
This commit is contained in:
@@ -841,6 +841,9 @@ local function _get_datetime(data, pos)
|
||||
if len == 7 then
|
||||
year, month, day, hour, minute, second, pos = string.unpack("<I2BBBBB", data, pos)
|
||||
value = strformat("%04d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second)
|
||||
elseif len == 4 then
|
||||
year, month, day, pos = string.unpack("<I2BB", data, pos)
|
||||
value = strformat("%04d-%02d-%02d %02d:%02d:%02d", year, month, day, 0, 0, 0)
|
||||
else
|
||||
value = "2017-09-09 20:08:09"
|
||||
--unsupported format
|
||||
|
||||
Reference in New Issue
Block a user