Current section
Files
Jump to
Current section
Files
src/glrss_parser@util.erl
-module(glrss_parser@util).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glrss_parser/util.gleam").
-export([year_2digit_to_full/1, try_unwrap/3]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-file("src/glrss_parser/util.gleam", 6).
?DOC(false).
-spec year_2digit_to_full(integer()) -> integer().
year_2digit_to_full(Year_2digit) ->
Current_year = glrss_parser_ffi:current_year(),
Current_century_year = (Current_year div 100) * 100,
Current_2digit = (Current_year rem 100) + 1,
case Year_2digit > Current_2digit of
true ->
(Year_2digit + Current_century_year) - 100;
false ->
Year_2digit + Current_century_year
end.
-file("src/glrss_parser/util.gleam", 29).
?DOC(false).
-spec try_unwrap(
{ok, KTY} | {error, KTZ},
KUC,
fun((KTY) -> {ok, KUC} | {error, KTZ})
) -> KUC.
try_unwrap(Result, Unwrap, Fun) ->
case Result of
{ok, A} ->
case Fun(A) of
{ok, B} ->
B;
{error, _} ->
Unwrap
end;
{error, _} ->
Unwrap
end.