Skip to content

Commit 9b4a950

Browse files
authored
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 <[email protected]>`
1 parent 0a1b2ba commit 9b4a950

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

spec/timestamp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type Timestamp uint64
99

1010
// AsTimestamp turns a time.Time into a millisecond posix timestamp.
1111
func AsTimestamp(t time.Time) Timestamp {
12-
return Timestamp(t.UnixNano() / 1000000)
12+
return Timestamp(t.UnixMilli())
1313
}
1414

1515
// Time turns a millisecond posix timestamp into a UTC time.Time

0 commit comments

Comments
 (0)