It is possible to use relative time in 2 ways:
- give a more or less complete datetime string, which will simply be parsed
- give a relative time expression, which can reference the current time (
now) and other so called "markers", which can be defined by the application
datetime- all markers are datetimes, and the result of the expression must also be a datetimeunit- The following time units are supported:s(seconds),m(minutes),h(hours),d(days),w(weeks),M(months), andy(years).interval- intervals are a duration and are represented by a number and aunit
datetime+interval::datetimeshifts the lhs datetime to the future by the lhs intervaldatetime-interval::datetimeshifts the lhs datetime into the past by the rhs intervaldatetime/unit::datetimeTruncates the given datetime to either the start or end of the given unit, depending on whetherfromortowas called.
If available in Hex, the package can be installed
by adding relative_time to your list of dependencies in mix.exs:
def deps do
[
{:relative_time, "~> 0.1.0"}
]
endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/relative_time.