philomena-dev / philomena

Next-generation imageboard
GNU Affero General Public License v3.0
92 stars 36 forks source link

Shorten truncated utc_now pattern #325

Closed liamwhite closed 4 months ago

liamwhite commented 4 months ago

Ecto automatically rejects format conversions which would lose precision, including storing a date with 1-microsecond precision to a column which only has 1-second precision. For this reason, datetimes must be truncated before storing.

Elixir v1.15 added DateTime.utc_now/1, which accepts an argument indicating that the returned value should be truncated, eliminating the need to explicitly truncate it in a second step.