Membrane Core v0.5.0 Membrane.Time View Source
Module containing functions needed to perform handling of time.
Membrane always internally uses nanosecond as a time unit. This is how all time units should represented in the code unless there's a good reason to act differently.
Please note that Erlang VM may internally use different units and that may differ from platform to platform. Still, unless you need to perform calculations that do not touch hardware clock, you should use Membrane units for consistency.
Link to this section Summary
Functions
Returns given days in internal Membrane time units.
The same as day/1
.
Converts DateTime
to internal Membrane time units.
Converts iso8601 string to internal Membrane time units.
If value
is invalid, throws match error.
Returns given hours in internal Membrane time units.
The same as hour/1
.
Checks whether value is Membrane.Time.native_t
Checks whether value is Membrane.Time.t
Returns given microseconds in internal Membrane time units.
The same as microsecond/1
.
Returns given milliseconds in internal Membrane time units.
The same as millisecond/1
.
Returns given minutes in internal Membrane time units.
The same as minute/1
.
Returns current monotonic time based on System.monotonic_time/0
in internal Membrane time units.
Returns given nanoseconds in internal Membrane time units.
The same as nanosecond/1
.
Returns given native units in internal Membrane time units.
The same as native_unit/1
.
Returns current POSIX time of operating system in internal Membrane time units.
Returns duration as a string with unit. Chosen unit is the biggest possible that doesn't involve precission loss.
Returns current time in pretty format (currently iso8601), as string
Uses system_time/0
under the hood.
Returns given seconds in internal Membrane time units.
The same as second/1
.
Returns current time of Erlang VM based on System.system_time/0
in internal Membrane time units.
Returns quoted code producing given amount time. Chosen unit is the biggest possible that doesn't involve precission loss.
Returns string representation of result of to_code/1
.
Returns time as a DateTime
struct. TimeZone is set to UTC.
Returns time in days. Rounded using Kernel.round/1
Returns time in hours. Rounded using Kernel.round/1
Returns time as a iso8601 string.
Returns time in microseconds. Rounded using Kernel.round/1
Returns time in milliseconds. Rounded using Kernel.round/1
Returns time in minutes. Rounded using Kernel.round/1
Returns time in nanoseconds. Rounded using Kernel.round/1
Returns time in system native units. Rounded using Kernel.round/1
Returns time in seconds. Rounded using Kernel.round/1
Returns current Erlang VM system time based on System.system_time/0
in internal Membrane time units.
Link to this section Types
Link to this section Functions
Returns given days in internal Membrane time units.
Inlined by the compiler.
The same as day/1
.
Inlined by the compiler.
Converts DateTime
to internal Membrane time units.
Inlined by the compiler.
Converts iso8601 string to internal Membrane time units.
If value
is invalid, throws match error.
Inlined by the compiler.
Returns given hours in internal Membrane time units.
Inlined by the compiler.
The same as hour/1
.
Inlined by the compiler.
Checks whether value is Membrane.Time.native_t
Checks whether value is Membrane.Time.t
Returns given microseconds in internal Membrane time units.
Inlined by the compiler.
The same as microsecond/1
.
Inlined by the compiler.
Returns given milliseconds in internal Membrane time units.
Inlined by the compiler.
The same as millisecond/1
.
Inlined by the compiler.
Returns given minutes in internal Membrane time units.
Inlined by the compiler.
The same as minute/1
.
Inlined by the compiler.
Returns current monotonic time based on System.monotonic_time/0
in internal Membrane time units.
Inlined by the compiler.
Returns given nanoseconds in internal Membrane time units.
Inlined by the compiler.
The same as nanosecond/1
.
Inlined by the compiler.
Returns given native units in internal Membrane time units.
Inlined by the compiler.
The same as native_unit/1
.
Inlined by the compiler.
Returns current POSIX time of operating system in internal Membrane time units.
Inlined by the compiler.
Returns duration as a string with unit. Chosen unit is the biggest possible that doesn't involve precission loss.
Examples
iex> import Membrane.Time
iex> 10 |> milliseconds() |> pretty_duration()
"10 ms"
iex> 60_000_000 |> microseconds() |> pretty_duration()
"1 min"
iex> 2 |> nanoseconds() |> pretty_duration()
"2 ns"
Returns current time in pretty format (currently iso8601), as string
Uses system_time/0
under the hood.
Returns given seconds in internal Membrane time units.
Inlined by the compiler.
The same as second/1
.
Inlined by the compiler.
Returns current time of Erlang VM based on System.system_time/0
in internal Membrane time units.
Inlined by the compiler.
Returns quoted code producing given amount time. Chosen unit is the biggest possible that doesn't involve precission loss.
Examples
iex> import Membrane.Time
iex> 10 |> milliseconds() |> to_code() |> Macro.to_string()
quote do 10 |> Membrane.Time.milliseconds() end |> Macro.to_string()
iex> 60_000_000 |> microseconds() |> to_code() |> Macro.to_string()
quote do 1 |> Membrane.Time.minutes() end |> Macro.to_string()
iex> 2 |> nanoseconds() |> to_code() |> Macro.to_string()
quote do 2 |> Membrane.Time.nanoseconds() end |> Macro.to_string()
Returns string representation of result of to_code/1
.
Returns time as a DateTime
struct. TimeZone is set to UTC.
Inlined by the compiler.
Returns time in days. Rounded using Kernel.round/1
Inlined by the compiler.
Returns time in hours. Rounded using Kernel.round/1
Inlined by the compiler.
Returns time as a iso8601 string.
Inlined by the compiler.
Returns time in microseconds. Rounded using Kernel.round/1
Inlined by the compiler.
Returns time in milliseconds. Rounded using Kernel.round/1
Inlined by the compiler.
Returns time in minutes. Rounded using Kernel.round/1
Inlined by the compiler.
Returns time in nanoseconds. Rounded using Kernel.round/1
Inlined by the compiler.
Returns time in system native units. Rounded using Kernel.round/1
Inlined by the compiler.
Returns time in seconds. Rounded using Kernel.round/1
Inlined by the compiler.
Returns current Erlang VM system time based on System.system_time/0
in internal Membrane time units.
It is the VM view of the os_time/0
. They may not match in case of time warps.
It is not monotonic.
Inlined by the compiler.