Current section
Files
Jump to
Current section
Files
src/gtz.erl
-module(gtz).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([timezone/1, local_name/0]).
-file("/home/john/Repos/gtz/src/gtz.gleam", 21).
-spec timezone(binary()) -> {ok, tempo:time_zone_provider()} | {error, nil}.
timezone(Name) ->
case 'Elixir.GTZ_FFI':is_valid_timezone(Name) of
true ->
{ok,
{time_zone_provider,
fun() -> Name end,
fun(Utc_naive_datetime) ->
{{Year, Month, Day}, {Hour, Minute, Second}} = tempo@naive_datetime:to_tuple(
Utc_naive_datetime
),
_assert_subject = begin
_pipe = 'Elixir.GTZ_FFI':calculate_offset(
Year,
Month,
Day,
Hour,
Minute,
Second,
Name
),
tempo@offset:new(_pipe)
end,
{ok, Offset} = case _assert_subject of
{ok, _} -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail,
module => <<"gtz"/utf8>>,
function => <<"timezone"/utf8>>,
line => 31})
end,
Offset
end}};
false ->
{error, nil}
end.
-file("/home/john/Repos/gtz/src/gtz.gleam", 69).
-spec local_name() -> binary().
local_name() ->
'Elixir.Timex.Timezone.Local':lookup().