fix: 当 mysql 数据库日期类型(timestamp, datetime)的字段,数据值没有 "时间部分(时分秒)" 时,比如 "2019-01-01" (#1879)

数据的长度是4(年2,月1, 日1),
而不是预期的7(年2,月1, 日1, 时1, 分1, 秒1)
This commit is contained in:
coldskycoldsky
2024-03-01 14:08:27 +08:00
committed by GitHub
parent 267cf5384c
commit bd5f12b959

View File

@@ -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