Membrane Core v0.1.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 input 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

Returns given milliseconds in internal Membrane time units

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

Returns given native units in internal Membrane time units

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 POSIX time based on System.system_time/0 in internal Membrane time units

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

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.

Link to this function from_datetime(value) View Source
from_datetime(DateTime.t()) :: t()

Converts DateTime to internal Membrane time units.

Inlined by the compiler.

Link to this function from_iso8601!(value) View Source
from_iso8601!(String.t()) :: t()

Converts iso8601 string to internal Membrane time units. If input 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.

Link to this macro is_native_t(value) View Source (macro)
is_native_t(any()) :: boolean()

Checks whether value is Membrane.Time.native_t

Link to this macro is_t(value) View Source (macro)
is_t(any()) :: boolean()

Checks whether value is Membrane.Time.t

Link to this function microsecond(value) View Source
microsecond(integer()) :: t()

Returns given microseconds in internal Membrane time units.

Inlined by the compiler.

Link to this function microseconds(value) View Source
microseconds(integer()) :: t()

The same as microsecond/1.

Inlined by the compiler.

Link to this function millisecond(value) View Source
millisecond(integer()) :: t()

Returns given milliseconds in internal Membrane time units.

Inlined by the compiler.

Link to this function milliseconds(value) View Source
milliseconds(integer()) :: t()

The same as millisecond/1.

Inlined by the compiler.

Link to this function minute(value) View Source
minute(integer()) :: t()

Returns given minutes in internal Membrane time units.

Inlined by the compiler.

Link to this function minutes(value) View Source
minutes(integer()) :: t()

The same as minute/1.

Inlined by the compiler.

Link to this function monotonic_time() View Source
monotonic_time() :: t()

Returns current monotonic time based on System.monotonic_time/0 in internal Membrane time units.

Inlined by the compiler.

Link to this function nanosecond(value) View Source
nanosecond(integer()) :: t()

Returns given nanoseconds in internal Membrane time units.

Inlined by the compiler.

Link to this function nanoseconds(value) View Source
nanoseconds(integer()) :: t()

The same as nanosecond/1.

Inlined by the compiler.

Link to this function native_unit(value) View Source
native_unit(native_t()) :: t()

Returns given native units in internal Membrane time units.

Inlined by the compiler.

Link to this function native_units(value) View Source
native_units(native_t()) :: t()

The same as native_unit/1.

Inlined by the compiler.

Link to this function pretty_now() View Source
pretty_now() :: String.t()

Returns current time in pretty format (currently iso8601), as string Uses system_time/0 under the hood.

Link to this function second(value) View Source
second(integer()) :: t()

Returns given seconds in internal Membrane time units.

Inlined by the compiler.

Link to this function seconds(value) View Source
seconds(integer()) :: t()

The same as second/1.

Inlined by the compiler.

Link to this function system_time() View Source
system_time() :: t()

Returns current POSIX time based on System.system_time/0 in internal Membrane time units.

Inlined by the compiler.

Link to this function to_datetime(value) View Source
to_datetime(t()) :: DateTime.t()

Returns time as a DateTime struct. TimeZone is set to UTC.

Inlined by the compiler.

Link to this function to_days(value) View Source
to_days(t()) :: integer()

Returns time in days. Rounded using Kernel.round/1

Inlined by the compiler.

Link to this function to_hours(value) View Source
to_hours(t()) :: integer()

Returns time in hours. Rounded using Kernel.round/1

Inlined by the compiler.

Link to this function to_iso8601(value) View Source
to_iso8601(t()) :: String.t()

Returns time as a iso8601 string.

Inlined by the compiler.

Link to this function to_microseconds(value) View Source
to_microseconds(t()) :: integer()

Returns time in microseconds. Rounded using Kernel.round/1

Inlined by the compiler.

Link to this function to_milliseconds(value) View Source
to_milliseconds(t()) :: integer()

Returns time in milliseconds. Rounded using Kernel.round/1

Inlined by the compiler.

Link to this function to_minutes(value) View Source
to_minutes(t()) :: integer()

Returns time in minutes. Rounded using Kernel.round/1

Inlined by the compiler.

Link to this function to_nanoseconds(value) View Source
to_nanoseconds(t()) :: integer()

Returns time in nanoseconds. Rounded using Kernel.round/1

Inlined by the compiler.

Link to this function to_native_units(value) View Source
to_native_units(t()) :: native_t()

Returns time in system native units. Rounded using Kernel.round/1

Inlined by the compiler.

Link to this function to_seconds(value) View Source
to_seconds(t()) :: integer()

Returns time in seconds. Rounded using Kernel.round/1

Inlined by the compiler.