phasedb v0.0.2 PhaseDB.TimeHelpers

Helpful functions for dealing with datetimes and intervals.

Summary

Functions

Return the current time minus the interval

Turn a Calendar.DateTime into UTC microseconds

Convert an interval into an approximate description

Returns true if the accuracy of the UTC microseconds match the specified resolution

Return the current time in UTC as a Calendar.DateTime

Return the current time in UTC microseconds

Convert UTC microseconds back to a Calendar.DateTime

Remove accuracy from UTC microseconds according to the specified resolution

Create a time interval in UTC microseconds based on a count and a unit

Types

interval_unit_med ::
  :usec |
  :usecs |
  :msec |
  :msecs |
  :sec |
  :secs |
  :min |
  :mins |
  :hour |
  :hours |
  :day |
  :days |
  :week |
  :weeks |
  :year |
  :years
interval_unit_short ::
  :u |
  :ms |
  :s |
  :m |
  :h |
  :d |
  :w |
  :y
interval_usecs :: integer
utc_usecs :: integer

Functions

ago(usecs, opts \\ [])

Return the current time minus the interval.

in_usecs(time)

Specs

in_usecs(Calendar.DateTime.t) :: utc_usecs

Turn a Calendar.DateTime into UTC microseconds.

interval_to_string(interval)

Specs

interval_to_string(interval_usecs) :: String.t

Convert an interval into an approximate description.

matches_resolution?(usecs, res)

Specs

matches_resolution?(utc_usecs, interval_usecs) :: boolean

Returns true if the accuracy of the UTC microseconds match the specified resolution.

now()

Specs

now :: Calendar.DateTime.t

Return the current time in UTC as a Calendar.DateTime.

now_in_usecs()

Specs

now_in_usecs :: utc_usecs

Return the current time in UTC microseconds.

to_datetime(usecs)

Specs

to_datetime(utc_usecs) :: Calendar.DateTime.t

Convert UTC microseconds back to a Calendar.DateTime.

to_resolution(usecs, res)

Specs

to_resolution(utc_usecs, interval_usecs) :: utc_usecs

Remove accuracy from UTC microseconds according to the specified resolution.

usecs(n, atom)

Specs

usecs(n :: integer, unit :: interval_unit) :: interval_usecs

Create a time interval in UTC microseconds based on a count and a unit.