Skip to content

Tiny library that makes easier the manipulation of Unix timestamps, named after a voodoo Loa

Notifications You must be signed in to change notification settings

ZuraGuerra/dumballah

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dumballah

Build Status Inline docs Deps Status Hex version

![Dumballah](http://snakespirit.webs.com/damballa4.jpg) ---

Dumballah is a tiny library that provides conversions between seconds and other time units, and some useful calculations to make easier the manipulation of Unix timestamps.

Dumballah is a voodoo Loa associated with the rain and the crops, that's why I chose his name for a library about time.

Here is the documentation.

Requirements

Elixir 1.3+.

## Installation

Just add it to your mix.exs file:

defp deps do
  [{:dumballah, "~> 2.3"}]
end

Usage

Conversions

From :hours, :days and :minutes to seconds.

Dumballah.Convert.to_seconds(:hours, 7)
> 25200

And viceversa.

Dumballah.Convert.from_seconds(:hours, 25200)
> 7.0

Calculations

Add and subtract :hours, :days and :minutes in seconds.

Dumballah.now
|> Dumballah.Calculate.add_time(:days, 1)
> 1473962718

Identify passed timestamps.

Dumballah.now
|> Dumballah.Calculate.has_passed?
> true

And more, like date_from_dawn/1 and seconds_until_midnight/1: check the docs.

Notes

Dumballah.now/0 returns your current local time in seconds. If you need the current UTC time, use DateTime.utc_now/0, which is part of the Elixir standard library since 1.3.

Recommended Readings

Working with date times is a real pain; these links provide some insights on how the Erlang VM deals with time. You might find them useful.

calendar module docs

os:timestamp/0 docs

time/0 docs

Time Correction in Erlang


Sponsored by steed.

steed.

About

Tiny library that makes easier the manipulation of Unix timestamps, named after a voodoo Loa

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages