From 9b4a950c38bc426a6dc0b54cd40a5f1ccbbb983f Mon Sep 17 00:00:00 2001 From: Roman Isaev Date: Mon, 27 Jan 2025 19:07:48 +0000 Subject: [PATCH] Minor improvement of spec.AsTimestamp (#447) It is a bit safer to convert `time.Time` using a standard `t.UnixMilli()` method rather than `t.UnixNano() / 1000000` ### Pull Request Checklist * [x] Pull request includes a [sign off](https://github.com/matrix-org/dendrite/blob/master/docs/CONTRIBUTING.md#sign-off) Signed-off-by: `Roman Isaev ` --- spec/timestamp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/timestamp.go b/spec/timestamp.go index ef120db0..3af0fde5 100644 --- a/spec/timestamp.go +++ b/spec/timestamp.go @@ -9,7 +9,7 @@ type Timestamp uint64 // AsTimestamp turns a time.Time into a millisecond posix timestamp. func AsTimestamp(t time.Time) Timestamp { - return Timestamp(t.UnixNano() / 1000000) + return Timestamp(t.UnixMilli()) } // Time turns a millisecond posix timestamp into a UTC time.Time