-module(tempo@offset). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([new/1, to_string/1, from_string/1, literal/1, to_duration/1, local_minutes/0, local/0, local_nano/0]). -file("/home/john/Repos/tempo/src/tempo/offset.gleam", 19). -spec new(integer()) -> {ok, tempo:offset()} | {error, tempo:error()}. new(Minutes) -> tempo:new_offset(Minutes). -file("/home/john/Repos/tempo/src/tempo/offset.gleam", 59). -spec to_string(tempo:offset()) -> binary(). to_string(Offset) -> {Is_negative, Hours} = case tempo:offset_get_minutes(Offset) div 60 of H when H =< 0 -> {true, - H}; H@1 -> {false, H@1} end, Mins = case tempo:offset_get_minutes(Offset) rem 60 of M when M < 0 -> - M; M@1 -> M@1 end, case {Is_negative, Hours, Mins} of {_, 0, 0} -> <<"-00:00"/utf8>>; {_, 0, M@2} -> <<"-00:"/utf8, (begin _pipe = gleam@int:to_string(M@2), gleam@string:pad_left(_pipe, 2, <<"0"/utf8>>) end)/binary>>; {true, H@2, M@3} -> <<<<<<"-"/utf8, (begin _pipe@1 = gleam@int:to_string(H@2), gleam@string:pad_left(_pipe@1, 2, <<"0"/utf8>>) end)/binary>>/binary, ":"/utf8>>/binary, (begin _pipe@2 = gleam@int:to_string(M@3), gleam@string:pad_left(_pipe@2, 2, <<"0"/utf8>>) end)/binary>>; {false, H@3, M@4} -> <<<<<<"+"/utf8, (begin _pipe@3 = gleam@int:to_string(H@3), gleam@string:pad_left(_pipe@3, 2, <<"0"/utf8>>) end)/binary>>/binary, ":"/utf8>>/binary, (begin _pipe@4 = gleam@int:to_string(M@4), gleam@string:pad_left(_pipe@4, 2, <<"0"/utf8>>) end)/binary>> end. -file("/home/john/Repos/tempo/src/tempo/offset.gleam", 99). -spec from_string(binary()) -> {ok, tempo:offset()} | {error, tempo:error()}. from_string(Offset) -> tempo:offset_from_string(Offset). -file("/home/john/Repos/tempo/src/tempo/offset.gleam", 37). -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 => 40}); {error, offset_out_of_bounds} -> erlang:error(#{gleam_error => panic, message => <<"Invalid offset literal value"/utf8>>, module => <<"tempo/offset"/utf8>>, function => <<"literal"/utf8>>, line => 41}); {error, _} -> erlang:error(#{gleam_error => panic, message => <<"Invalid offset literal"/utf8>>, module => <<"tempo/offset"/utf8>>, function => <<"literal"/utf8>>, line => 42}) end. -file("/home/john/Repos/tempo/src/tempo/offset.gleam", 104). -spec to_duration(tempo:offset()) -> tempo:duration(). to_duration(Offset) -> _pipe = - tempo:offset_get_minutes(Offset) * 60000000000, tempo:duration(_pipe). -file("/home/john/Repos/tempo/src/tempo/offset.gleam", 111). -spec local_minutes() -> integer(). local_minutes() -> tempo_ffi:local_offset(). -file("/home/john/Repos/tempo/src/tempo/offset.gleam", 6). -spec local() -> tempo:offset(). local() -> _pipe = tempo_ffi:local_offset(), tempo:offset(_pipe). -file("/home/john/Repos/tempo/src/tempo/offset.gleam", 114). -spec local_nano() -> integer(). local_nano() -> tempo_ffi:local_offset() * 60000000000.