-module(glrss_parser@util). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([year_2digit_to_full/1, try_unwrap/3]). -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. -spec try_unwrap( {ok, KZS} | {error, KZT}, KZW, fun((KZS) -> {ok, KZW} | {error, KZT}) ) -> KZW. try_unwrap(Result, Unwrap, Fun) -> case Result of {ok, A} -> case Fun(A) of {ok, B} -> B; {error, _} -> Unwrap end; {error, _} -> Unwrap end.