diff --git a/CHANGELOG.md b/CHANGELOG.md index a0087787..3f9c343c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,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 diff --git a/tools/types/datetime.go b/tools/types/datetime.go index f96869d0..70bf3f34 100644 --- a/tools/types/datetime.go +++ b/tools/types/datetime.go @@ -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 == "" { diff --git a/tools/types/datetime_test.go b/tools/types/datetime_test.go index c42f73d6..60cbe5f8 100644 --- a/tools/types/datetime_test.go +++ b/tools/types/datetime_test.go @@ -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"}, }