AgoTimes
This library aims to ease creation of past times in Elixir. For example
# This creates a DateTime for 2 days ago
DateRange.ago 2, :daysIt also has helpers for Ecto. For example
# Create a Ecto.DateTime for 2 days ago
EctoRange.ago 2, :daysInstallation
The package can be installed as:
-
Add
ago_timesto your list of dependencies inmix.exs:
```elixir
def deps do
[{:ago_times, "~> 0.1.0"}]
end
```- Have fun!
How to use
Since this is a library, there is no application to start after installation. There is only one function, ago/2 defined in both modules DateRange and EctoRange. In the following examples, you can replace DateRange with EctoRange to get Ecto.DateTime instead of DateTime.
# Seconds ago
DateRange 2, :seconds
# Minutes ago
DateRange 2, :minutes
# Hours ago
DateRange 2, :hours
# Days ago
DateRange 2, :days
# Weeks ago
DateRange 2, :weeks