Skip to content

Commit

Permalink
Update lib/credo/check/refactor/utc_now_truncate.ex
Browse files Browse the repository at this point in the history
Co-authored-by: René Föhring <rf@bamaru.de>
  • Loading branch information
frerich and rrrene authored Dec 16, 2023
1 parent ef89703 commit 46e9ca6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/credo/check/refactor/utc_now_truncate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ defmodule Credo.Check.Refactor.UtcNowTruncate do
check: """
`DateTime.utc_now/1` is more efficient than `DateTime.utc_now/0 |> DateTime.truncate/1`.
This should be refactored:
For example, the code here ...
DateTime.utc_now() |> DateTime.truncate(:second)
NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
to look like this:
... can be refactored to look like this:
DateTime.utc_now(:second)
Dito for `NaiveDateTime`.
NaiveDateTime.utc_now(:second)
The reason for this is not just performance, because no separate function
call is required, but also brevity of the resulting code.
Expand Down

0 comments on commit 46e9ca6

Please sign in to comment.