1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2024-11-24 17:07:00 +02:00

[#2602] added common int types support when scanning types.DateTime

This commit is contained in:
Gani Georgiev 2023-05-30 20:43:20 +03:00
parent dbbc1e25ca
commit 3122223a71
3 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,8 @@
- Fixed the selfupdate command not working on Windows due to missing `.exe` in the extracted binary path ([#2589](https://github.com/pocketbase/pocketbase/discussions/2589)).
- Added `int64`, `int32`, `uint`, `uint64` and `uint32` support when scanning `types.DateTime` ([#2602](https://github.com/pocketbase/pocketbase/discussions/2602))
## v0.16.3

View File

@ -78,7 +78,7 @@ func (d *DateTime) Scan(value any) error {
d.t = v.Time()
case time.Time:
d.t = v
case int:
case int, int64, int32, uint, uint64, uint32:
d.t = cast.ToTime(v)
case string:
if v == "" {

View File

@ -32,6 +32,11 @@ func TestParseDateTime(t *testing.T) {
{nowDateTime, nowStr},
{nowTime, nowStr},
{1641024040, "2022-01-01 08:00:40.000Z"},
{int32(1641024040), "2022-01-01 08:00:40.000Z"},
{int64(1641024040), "2022-01-01 08:00:40.000Z"},
{uint(1641024040), "2022-01-01 08:00:40.000Z"},
{uint64(1641024040), "2022-01-01 08:00:40.000Z"},
{uint32(1641024040), "2022-01-01 08:00:40.000Z"},
{"2022-01-01 11:23:45.678", "2022-01-01 11:23:45.678Z"},
}