Skip to content

Commit

Permalink
Minor improvement of spec.AsTimestamp (#447)
Browse files Browse the repository at this point in the history
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]>`
  • Loading branch information
mdnight authored Jan 27, 2025
1 parent 0a1b2ba commit 9b4a950
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion spec/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9b4a950

Please sign in to comment.