Current section

Files

Jump to
gtempo src tempo@offset.erl
Raw

src/tempo@offset.erl

-module(tempo@offset).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([local/0, new/1, to_string/1, from_string/1, literal/1, describe_parse_error/1]).
-file("/home/john/tempo/src/tempo/offset.gleam", 23).
-spec local() -> tempo:offset().
local() ->
_pipe = tempo_ffi:local_offset(),
tempo:offset(_pipe).
-file("/home/john/tempo/src/tempo/offset.gleam", 36).
-spec new(integer()) -> {ok, tempo:offset()} | {error, nil}.
new(Minutes) ->
tempo:new_offset(Minutes).
-file("/home/john/tempo/src/tempo/offset.gleam", 77).
-spec to_string(tempo:offset()) -> binary().
to_string(Offset) ->
tempo:offset_to_string(Offset).
-file("/home/john/tempo/src/tempo/offset.gleam", 91).
-spec from_string(binary()) -> {ok, tempo:offset()} |
{error, tempo@error:offset_parse_error()}.
from_string(Offset) ->
tempo:offset_from_string(Offset).
-file("/home/john/tempo/src/tempo/offset.gleam", 54).
-spec literal(binary()) -> tempo:offset().
literal(Offset) ->
case from_string(Offset) of
{ok, Offset@1} ->
Offset@1;
{error, {offset_invalid_format, _}} ->
erlang:error(#{gleam_error => panic,
message => <<"Invalid offset literal format"/utf8>>,
module => <<"tempo/offset"/utf8>>,
function => <<"literal"/utf8>>,
line => 58});
{error, {offset_out_of_bounds, _}} ->
erlang:error(#{gleam_error => panic,
message => <<"Invalid offset literal value"/utf8>>,
module => <<"tempo/offset"/utf8>>,
function => <<"literal"/utf8>>,
line => 60})
end.
-file("/home/john/tempo/src/tempo/offset.gleam", 106).
-spec describe_parse_error(tempo@error:offset_parse_error()) -> binary().
describe_parse_error(Error) ->
tempo@error:describe_offset_parse_error(Error).