Clarify calendar add always converts to microseconds

This commit is contained in:
José Valim
2025-11-17 08:29:48 -08:00
parent 7989e87716
commit 46807cfcdf
3 changed files with 9 additions and 6 deletions
+3 -2
View File
@@ -1622,8 +1622,9 @@ defmodule DateTime do
Accepts an `amount_to_add` in any `unit`. `unit` can be `:day`,
`:hour`, `:minute`, `:second` or any subsecond precision from
`t:System.time_unit/0`. It defaults to `:second`. Negative values
will move backwards in time.
`t:System.time_unit/0` for convenience but ultimately they are
all converted to microseconds. Negative values will move backwards
in time and the default precision is `:second`.
This function relies on a contiguous representation of time,
ignoring timezone changes. For example, if you add one day when there
+3 -2
View File
@@ -402,8 +402,9 @@ defmodule NaiveDateTime do
Accepts an `amount_to_add` in any `unit`. `unit` can be `:day`,
`:hour`, `:minute`, `:second` or any subsecond precision from
`t:System.time_unit/0`. It defaults to `:second`. Negative values
will move backwards in time.
`t:System.time_unit/0` for convenience but ultimately they are
all converted to microseconds. Negative values will move backwards
in time and the default precision is `:second`.
## Examples
+3 -2
View File
@@ -514,8 +514,9 @@ defmodule Time do
Accepts an `amount_to_add` in any `unit`. `unit` can be
`:hour`, `:minute`, `:second` or any subsecond precision from
`t:System.time_unit/0`. It defaults to `:second`. Negative values
will move backwards in time.
`t:System.time_unit/0` for convenience but ultimately they are
all converted to microseconds. Negative values will move backwards
in time and the default precision is `:second`.
Note the result value represents the time of day, meaning that it is cyclic,
for instance, it will never go over 24 hours for the ISO calendar.