-module(birl@time). -compile([no_auto_import, nowarn_unused_vars]). -export([to_unix/1, from_unix/1, compare/2, difference/2, legible_difference/2, add/2, subtract/2, range/3, set_timezone/2, get_timezone/1, set_offset/2, get_offset/1, utc_now/0, now_with_offset/1, now_with_timezone/1, monotonic_now/0, to_iso8601/1, to_naive/1, month/1, string_month/1, short_string_month/1, get_date/1, get_time/1, to_erlang_datetime/1, to_erlang_universal_datetime/1, from_iso8601/1, from_naive/1, set_date/2, set_time/2, from_erlang_universal_datetime/1, weekday/1, string_weekday/1, short_string_weekday/1, to_http/1, to_http_with_offset/1, from_http/1, local_timezone/0, now/0, from_erlang_local_datetime/1]). -export_type([date_time/0, date/0, time/0, weekday/0, month/0]). -opaque date_time() :: {date_time, integer(), integer(), gleam@option:option(binary()), gleam@option:option(integer())}. -type date() :: {date, integer(), integer(), integer()}. -type time() :: {time, integer(), integer(), integer(), integer()}. -type weekday() :: mon | tue | wed | thu | fri | sat | sun. -type month() :: jan | feb | mar | apr | may | jun | jul | aug | sep | oct | nov | dec. -spec to_unix(date_time()) -> integer(). to_unix(Value) -> case Value of {date_time, T, _, _, _} -> T div 1000000 end. -spec from_unix(integer()) -> date_time(). from_unix(Value) -> {date_time, Value * 1000000, 0, none, none}. -spec compare(date_time(), date_time()) -> gleam@order:order(). compare(A, B) -> {date_time, Wta, _, _, Mta} = A, {date_time, Wtb, _, _, Mtb} = B, {Ta@1, Tb@1} = case {Mta, Mtb} of {{some, Ta}, {some, Tb}} -> {Ta, Tb}; _ -> {Wta, Wtb} end, case Ta@1 =:= Tb@1 of true -> eq; false -> case Ta@1 < Tb@1 of true -> lt; false -> gt end end. -spec difference(date_time(), date_time()) -> birl@duration:duration(). difference(A, B) -> {date_time, Wta, _, _, Mta} = A, {date_time, Wtb, _, _, Mtb} = B, {Ta@1, Tb@1} = case {Mta, Mtb} of {{some, Ta}, {some, Tb}} -> {Ta, Tb}; _ -> {Wta, Wtb} end, {duration, Ta@1 - Tb@1}. -spec legible_difference(date_time(), date_time()) -> binary(). legible_difference(A, B) -> case begin _pipe = difference(A, B), birl@duration:blur(_pipe) end of {_, micro_second} -> <<"just now"/utf8>>; {_, milli_second} -> <<"just now"/utf8>>; {Amount, Unit} -> _assert_subject = gleam@list:key_find( [{year, <<"year"/utf8>>}, {month, <<"month"/utf8>>}, {week, <<"week"/utf8>>}, {day, <<"day"/utf8>>}, {hour, <<"hour"/utf8>>}, {minute, <<"minute"/utf8>>}, {second, <<"second"/utf8>>}], Unit ), {ok, Unit@1} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"legible_difference"/utf8>>, line => 573}) end, Is_negative = Amount < 0, Amount@1 = gleam@int:absolute_value(Amount), Unit@2 = case Amount@1 of 1 -> Unit@1; _ -> <> end, case Is_negative of true -> <<<<<<"in "/utf8, (gleam@int:to_string(Amount@1))/binary>>/binary, " "/utf8>>/binary, Unit@2/binary>>; false -> <<<<<<(begin _pipe@1 = Amount@1, _pipe@2 = gleam@int:absolute_value(_pipe@1), gleam@int:to_string(_pipe@2) end)/binary, " "/utf8>>/binary, Unit@2/binary>>/binary, " ago"/utf8>> end end. -spec add(date_time(), birl@duration:duration()) -> date_time(). add(Value, Duration) -> {date_time, Wt, O, Timezone, Mt} = Value, {duration, Duration@1} = Duration, case Mt of {some, Mt@1} -> {date_time, Wt + Duration@1, O, Timezone, {some, Mt@1 + Duration@1}}; none -> {date_time, Wt + Duration@1, O, Timezone, none} end. -spec subtract(date_time(), birl@duration:duration()) -> date_time(). subtract(Value, Duration) -> {date_time, Wt, O, Timezone, Mt} = Value, {duration, Duration@1} = Duration, case Mt of {some, Mt@1} -> {date_time, Wt - Duration@1, O, Timezone, {some, Mt@1 - Duration@1}}; none -> {date_time, Wt - Duration@1, O, Timezone, none} end. -spec range( date_time(), gleam@option:option(date_time()), birl@duration:duration() ) -> gleam@iterator:iterator(date_time()). range(A, B, S) -> _assert_subject = case B of {some, B@1} -> (ranger:create( fun(_) -> true end, fun(Duration) -> {duration, Value} = Duration, {duration, -1 * Value} end, fun add/2, fun compare/2 ))(A, B@1, S); none -> (ranger:create_infinite( fun(_) -> true end, fun add/2, fun compare/2 ))(A, S) end, {ok, Range} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"range"/utf8>>, line => 684}) end, _pipe = Range, ranger:unwrap(_pipe). -spec set_timezone(date_time(), binary()) -> {ok, date_time()} | {error, nil}. set_timezone(Value, New_timezone) -> case begin _pipe = [{<<"America/Santarem"/utf8>>, -10800}, {<<"America/Ciudad_Juarez"/utf8>>, -25200}, {<<"Asia/Almaty"/utf8>>, 21600}, {<<"America/Manaus"/utf8>>, -14400}, {<<"America/Adak"/utf8>>, -36000}, {<<"EST5EDT"/utf8>>, -18000}, {<<"Europe/Belgrade"/utf8>>, 3600}, {<<"Asia/Famagusta"/utf8>>, 7200}, {<<"Asia/Kabul"/utf8>>, 16200}, {<<"America/Bahia_Banderas"/utf8>>, -21600}, {<<"America/Indiana/Vevay"/utf8>>, -18000}, {<<"Atlantic/Stanley"/utf8>>, -10800}, {<<"Africa/Ndjamena"/utf8>>, 3600}, {<<"Pacific/Marquesas"/utf8>>, -34200}, {<<"Atlantic/Azores"/utf8>>, -3600}, {<<"Asia/Jerusalem"/utf8>>, 7200}, {<<"Africa/Nairobi"/utf8>>, 10800}, {<<"Asia/Tehran"/utf8>>, 12600}, {<<"America/Anchorage"/utf8>>, -32400}, {<<"America/Belem"/utf8>>, -10800}, {<<"America/Paramaribo"/utf8>>, -10800}, {<<"Etc/GMT+3"/utf8>>, -10800}, {<<"Etc/GMT+10"/utf8>>, -36000}, {<<"Asia/Novokuznetsk"/utf8>>, 25200}, {<<"Africa/Monrovia"/utf8>>, 0}, {<<"Asia/Ho_Chi_Minh"/utf8>>, 25200}, {<<"Asia/Makassar"/utf8>>, 28800}, {<<"MST7MDT"/utf8>>, -25200}, {<<"Pacific/Rarotonga"/utf8>>, -36000}, {<<"America/Ojinaga"/utf8>>, -21600}, {<<"Europe/Helsinki"/utf8>>, 7200}, {<<"Europe/Tirane"/utf8>>, 3600}, {<<"America/Noronha"/utf8>>, -7200}, {<<"Etc/GMT-4"/utf8>>, 14400}, {<<"Etc/GMT-14"/utf8>>, 50400}, {<<"Atlantic/Bermuda"/utf8>>, -14400}, {<<"America/Indiana/Winamac"/utf8>>, -18000}, {<<"America/Nuuk"/utf8>>, -7200}, {<<"America/Rankin_Inlet"/utf8>>, -21600}, {<<"Atlantic/South_Georgia"/utf8>>, -7200}, {<<"America/Tijuana"/utf8>>, -28800}, {<<"Asia/Nicosia"/utf8>>, 7200}, {<<"Pacific/Pago_Pago"/utf8>>, -39600}, {<<"America/Barbados"/utf8>>, -14400}, {<<"Asia/Tomsk"/utf8>>, 25200}, {<<"Asia/Baku"/utf8>>, 14400}, {<<"America/Argentina/Buenos_Aires"/utf8>>, -10800}, {<<"Antarctica/Mawson"/utf8>>, 18000}, {<<"Australia/Broken_Hill"/utf8>>, 34200}, {<<"America/Bogota"/utf8>>, -18000}, {<<"Asia/Macau"/utf8>>, 28800}, {<<"Pacific/Tahiti"/utf8>>, -36000}, {<<"America/Thule"/utf8>>, -14400}, {<<"Indian/Maldives"/utf8>>, 18000}, {<<"America/Whitehorse"/utf8>>, -25200}, {<<"America/Indiana/Vincennes"/utf8>>, -18000}, {<<"America/Argentina/Rio_Gallegos"/utf8>>, -10800}, {<<"America/Fort_Nelson"/utf8>>, -25200}, {<<"Asia/Shanghai"/utf8>>, 28800}, {<<"America/Nome"/utf8>>, -32400}, {<<"Asia/Choibalsan"/utf8>>, 28800}, {<<"Pacific/Palau"/utf8>>, 32400}, {<<"America/Halifax"/utf8>>, -14400}, {<<"Etc/UTC"/utf8>>, 0}, {<<"Europe/Bucharest"/utf8>>, 7200}, {<<"Antarctica/Davis"/utf8>>, 25200}, {<<"Etc/GMT+4"/utf8>>, -14400}, {<<"Asia/Jakarta"/utf8>>, 25200}, {<<"Africa/Sao_Tome"/utf8>>, 0}, {<<"Asia/Qyzylorda"/utf8>>, 18000}, {<<"Asia/Hovd"/utf8>>, 25200}, {<<"Africa/Khartoum"/utf8>>, 7200}, {<<"Antarctica/Troll"/utf8>>, 0}, {<<"Asia/Anadyr"/utf8>>, 43200}, {<<"HST"/utf8>>, -36000}, {<<"CST6CDT"/utf8>>, -21600}, {<<"America/Glace_Bay"/utf8>>, -14400}, {<<"Africa/Tripoli"/utf8>>, 7200}, {<<"Europe/Berlin"/utf8>>, 3600}, {<<"Europe/Tallinn"/utf8>>, 7200}, {<<"America/La_Paz"/utf8>>, -14400}, {<<"America/Mazatlan"/utf8>>, -25200}, {<<"Pacific/Nauru"/utf8>>, 43200}, {<<"Asia/Sakhalin"/utf8>>, 39600}, {<<"America/Puerto_Rico"/utf8>>, -14400}, {<<"Pacific/Norfolk"/utf8>>, 39600}, {<<"America/Danmarkshavn"/utf8>>, 0}, {<<"Pacific/Auckland"/utf8>>, 43200}, {<<"America/Argentina/Catamarca"/utf8>>, -10800}, {<<"America/Porto_Velho"/utf8>>, -14400}, {<<"America/Cayenne"/utf8>>, -10800}, {<<"Etc/GMT-5"/utf8>>, 18000}, {<<"Pacific/Guadalcanal"/utf8>>, 39600}, {<<"America/Indiana/Tell_City"/utf8>>, -21600}, {<<"Asia/Kamchatka"/utf8>>, 43200}, {<<"Europe/Vilnius"/utf8>>, 7200}, {<<"Asia/Bishkek"/utf8>>, 21600}, {<<"America/New_York"/utf8>>, -18000}, {<<"America/Belize"/utf8>>, -21600}, {<<"Africa/Algiers"/utf8>>, 3600}, {<<"Asia/Yerevan"/utf8>>, 14400}, {<<"America/Jamaica"/utf8>>, -18000}, {<<"Europe/Madrid"/utf8>>, 3600}, {<<"Asia/Aqtau"/utf8>>, 18000}, {<<"Asia/Vladivostok"/utf8>>, 36000}, {<<"Europe/Kirov"/utf8>>, 10800}, {<<"Asia/Chita"/utf8>>, 32400}, {<<"WET"/utf8>>, 0}, {<<"Australia/Perth"/utf8>>, 28800}, {<<"America/Argentina/San_Juan"/utf8>>, -10800}, {<<"Asia/Yangon"/utf8>>, 23400}, {<<"America/Goose_Bay"/utf8>>, -14400}, {<<"Asia/Gaza"/utf8>>, 7200}, {<<"America/Chicago"/utf8>>, -21600}, {<<"Africa/Cairo"/utf8>>, 7200}, {<<"Asia/Seoul"/utf8>>, 32400}, {<<"America/Scoresbysund"/utf8>>, -3600}, {<<"Europe/Gibraltar"/utf8>>, 3600}, {<<"Europe/Volgograd"/utf8>>, 10800}, {<<"Asia/Urumqi"/utf8>>, 21600}, {<<"Asia/Irkutsk"/utf8>>, 28800}, {<<"America/Resolute"/utf8>>, -21600}, {<<"America/Martinique"/utf8>>, -14400}, {<<"America/Asuncion"/utf8>>, -14400}, {<<"Africa/El_Aaiun"/utf8>>, 3600}, {<<"America/Dawson"/utf8>>, -25200}, {<<"America/Panama"/utf8>>, -18000}, {<<"Asia/Novosibirsk"/utf8>>, 25200}, {<<"Antarctica/Palmer"/utf8>>, -10800}, {<<"Etc/GMT-8"/utf8>>, 28800}, {<<"America/Juneau"/utf8>>, -32400}, {<<"America/Guayaquil"/utf8>>, -18000}, {<<"Asia/Ulaanbaatar"/utf8>>, 28800}, {<<"Asia/Taipei"/utf8>>, 28800}, {<<"Pacific/Chatham"/utf8>>, 45900}, {<<"Etc/GMT+2"/utf8>>, -7200}, {<<"Europe/Budapest"/utf8>>, 3600}, {<<"America/Havana"/utf8>>, -18000}, {<<"Etc/GMT+12"/utf8>>, -43200}, {<<"Africa/Tunis"/utf8>>, 3600}, {<<"Asia/Kolkata"/utf8>>, 19800}, {<<"America/Denver"/utf8>>, -25200}, {<<"America/Menominee"/utf8>>, -21600}, {<<"Asia/Dhaka"/utf8>>, 21600}, {<<"Asia/Hong_Kong"/utf8>>, 28800}, {<<"Asia/Magadan"/utf8>>, 39600}, {<<"Asia/Pontianak"/utf8>>, 25200}, {<<"Asia/Dubai"/utf8>>, 14400}, {<<"America/Indiana/Petersburg"/utf8>>, -18000}, {<<"America/Winnipeg"/utf8>>, -21600}, {<<"America/Vancouver"/utf8>>, -28800}, {<<"America/Detroit"/utf8>>, -18000}, {<<"America/Bahia"/utf8>>, -10800}, {<<"Pacific/Galapagos"/utf8>>, -21600}, {<<"Africa/Windhoek"/utf8>>, 7200}, {<<"Pacific/Kiritimati"/utf8>>, 50400}, {<<"Etc/GMT-1"/utf8>>, 3600}, {<<"Europe/Andorra"/utf8>>, 3600}, {<<"America/Merida"/utf8>>, -21600}, {<<"Africa/Lagos"/utf8>>, 3600}, {<<"America/Mexico_City"/utf8>>, -21600}, {<<"Asia/Yekaterinburg"/utf8>>, 18000}, {<<"America/Argentina/Cordoba"/utf8>>, -10800}, {<<"Asia/Kuching"/utf8>>, 28800}, {<<"Asia/Manila"/utf8>>, 28800}, {<<"Australia/Lindeman"/utf8>>, 36000}, {<<"Asia/Dushanbe"/utf8>>, 18000}, {<<"Pacific/Pitcairn"/utf8>>, -28800}, {<<"Etc/GMT-12"/utf8>>, 43200}, {<<"America/Punta_Arenas"/utf8>>, -10800}, {<<"America/Maceio"/utf8>>, -10800}, {<<"America/Guyana"/utf8>>, -14400}, {<<"Asia/Pyongyang"/utf8>>, 32400}, {<<"Antarctica/Macquarie"/utf8>>, 36000}, {<<"Pacific/Kosrae"/utf8>>, 39600}, {<<"Africa/Juba"/utf8>>, 7200}, {<<"Indian/Mauritius"/utf8>>, 14400}, {<<"Antarctica/Rothera"/utf8>>, -10800}, {<<"Asia/Colombo"/utf8>>, 19800}, {<<"Asia/Barnaul"/utf8>>, 25200}, {<<"Europe/London"/utf8>>, 0}, {<<"Africa/Ceuta"/utf8>>, 3600}, {<<"America/Guatemala"/utf8>>, -21600}, {<<"Europe/Moscow"/utf8>>, 10800}, {<<"America/Indiana/Knox"/utf8>>, -21600}, {<<"America/Toronto"/utf8>>, -18000}, {<<"Australia/Sydney"/utf8>>, 36000}, {<<"Pacific/Kanton"/utf8>>, 46800}, {<<"Asia/Omsk"/utf8>>, 21600}, {<<"Etc/GMT+6"/utf8>>, -21600}, {<<"Europe/Samara"/utf8>>, 14400}, {<<"America/Kentucky/Louisville"/utf8>>, -18000}, {<<"America/Iqaluit"/utf8>>, -18000}, {<<"CET"/utf8>>, 3600}, {<<"Europe/Saratov"/utf8>>, 14400}, {<<"America/Argentina/Ushuaia"/utf8>>, -10800}, {<<"America/Regina"/utf8>>, -21600}, {<<"Etc/GMT-9"/utf8>>, 32400}, {<<"Etc/GMT+11"/utf8>>, -39600}, {<<"America/Boa_Vista"/utf8>>, -14400}, {<<"MET"/utf8>>, 3600}, {<<"Australia/Adelaide"/utf8>>, 34200}, {<<"EET"/utf8>>, 7200}, {<<"Africa/Casablanca"/utf8>>, 3600}, {<<"America/Chihuahua"/utf8>>, -21600}, {<<"America/Indiana/Marengo"/utf8>>, -18000}, {<<"America/Cambridge_Bay"/utf8>>, -25200}, {<<"Etc/GMT-10"/utf8>>, 36000}, {<<"Australia/Eucla"/utf8>>, 31500}, {<<"Asia/Srednekolymsk"/utf8>>, 39600}, {<<"Europe/Rome"/utf8>>, 3600}, {<<"America/Matamoros"/utf8>>, -21600}, {<<"America/Miquelon"/utf8>>, -10800}, {<<"Pacific/Honolulu"/utf8>>, -36000}, {<<"America/Eirunepe"/utf8>>, -18000}, {<<"Europe/Dublin"/utf8>>, 3600}, {<<"America/Santiago"/utf8>>, -14400}, {<<"America/Argentina/San_Luis"/utf8>>, -10800}, {<<"Asia/Beirut"/utf8>>, 7200}, {<<"Pacific/Fiji"/utf8>>, 43200}, {<<"America/Montevideo"/utf8>>, -10800}, {<<"Asia/Jayapura"/utf8>>, 32400}, {<<"Asia/Qostanay"/utf8>>, 21600}, {<<"Europe/Warsaw"/utf8>>, 3600}, {<<"Asia/Khandyga"/utf8>>, 32400}, {<<"America/Costa_Rica"/utf8>>, -21600}, {<<"America/Sao_Paulo"/utf8>>, -10800}, {<<"America/Argentina/Mendoza"/utf8>>, -10800}, {<<"America/Sitka"/utf8>>, -32400}, {<<"America/Kentucky/Monticello"/utf8>>, -18000}, {<<"America/Argentina/Tucuman"/utf8>>, -10800}, {<<"America/Fortaleza"/utf8>>, -10800}, {<<"America/Araguaina"/utf8>>, -10800}, {<<"America/Monterrey"/utf8>>, -21600}, {<<"Atlantic/Canary"/utf8>>, 0}, {<<"Asia/Atyrau"/utf8>>, 18000}, {<<"Australia/Lord_Howe"/utf8>>, 37800}, {<<"Etc/GMT-3"/utf8>>, 10800}, {<<"Pacific/Apia"/utf8>>, 46800}, {<<"Australia/Hobart"/utf8>>, 36000}, {<<"Europe/Prague"/utf8>>, 3600}, {<<"Asia/Aqtobe"/utf8>>, 18000}, {<<"Africa/Maputo"/utf8>>, 7200}, {<<"Asia/Oral"/utf8>>, 18000}, {<<"Europe/Athens"/utf8>>, 7200}, {<<"Etc/GMT+5"/utf8>>, -18000}, {<<"Europe/Simferopol"/utf8>>, 10800}, {<<"Europe/Brussels"/utf8>>, 3600}, {<<"America/Port-au-Prince"/utf8>>, -18000}, {<<"Etc/GMT-11"/utf8>>, 39600}, {<<"Etc/GMT+9"/utf8>>, -32400}, {<<"America/Argentina/Salta"/utf8>>, -10800}, {<<"Pacific/Niue"/utf8>>, -39600}, {<<"America/Los_Angeles"/utf8>>, -28800}, {<<"Australia/Brisbane"/utf8>>, 36000}, {<<"America/Boise"/utf8>>, -25200}, {<<"America/Edmonton"/utf8>>, -25200}, {<<"Pacific/Port_Moresby"/utf8>>, 36000}, {<<"Pacific/Bougainville"/utf8>>, 39600}, {<<"Asia/Tokyo"/utf8>>, 32400}, {<<"America/Yakutat"/utf8>>, -32400}, {<<"Pacific/Tongatapu"/utf8>>, 46800}, {<<"America/Inuvik"/utf8>>, -25200}, {<<"Indian/Chagos"/utf8>>, 21600}, {<<"America/Caracas"/utf8>>, -14400}, {<<"PST8PDT"/utf8>>, -28800}, {<<"Europe/Lisbon"/utf8>>, 0}, {<<"Asia/Damascus"/utf8>>, 10800}, {<<"Pacific/Efate"/utf8>>, 39600}, {<<"Asia/Karachi"/utf8>>, 18000}, {<<"America/Argentina/La_Rioja"/utf8>>, -10800}, {<<"Africa/Johannesburg"/utf8>>, 7200}, {<<"Australia/Melbourne"/utf8>>, 36000}, {<<"Etc/GMT"/utf8>>, 0}, {<<"Africa/Abidjan"/utf8>>, 0}, {<<"Asia/Dili"/utf8>>, 32400}, {<<"America/Lima"/utf8>>, -18000}, {<<"Europe/Istanbul"/utf8>>, 10800}, {<<"Asia/Ashgabat"/utf8>>, 18000}, {<<"America/Rio_Branco"/utf8>>, -18000}, {<<"America/El_Salvador"/utf8>>, -21600}, {<<"Pacific/Guam"/utf8>>, 36000}, {<<"America/Hermosillo"/utf8>>, -25200}, {<<"America/Metlakatla"/utf8>>, -32400}, {<<"Etc/GMT-7"/utf8>>, 25200}, {<<"Etc/GMT+7"/utf8>>, -25200}, {<<"Europe/Vienna"/utf8>>, 3600}, {<<"Europe/Kaliningrad"/utf8>>, 7200}, {<<"America/St_Johns"/utf8>>, -12600}, {<<"America/North_Dakota/New_Salem"/utf8>>, -21600}, {<<"Asia/Qatar"/utf8>>, 10800}, {<<"America/Recife"/utf8>>, -10800}, {<<"Asia/Thimphu"/utf8>>, 21600}, {<<"Pacific/Noumea"/utf8>>, 39600}, {<<"Europe/Sofia"/utf8>>, 7200}, {<<"Atlantic/Cape_Verde"/utf8>>, -3600}, {<<"Europe/Minsk"/utf8>>, 10800}, {<<"America/Swift_Current"/utf8>>, -21600}, {<<"Europe/Ulyanovsk"/utf8>>, 14400}, {<<"Europe/Kyiv"/utf8>>, 7200}, {<<"Etc/GMT+8"/utf8>>, -28800}, {<<"America/Phoenix"/utf8>>, -25200}, {<<"Pacific/Easter"/utf8>>, -21600}, {<<"America/Argentina/Jujuy"/utf8>>, -10800}, {<<"Asia/Tashkent"/utf8>>, 18000}, {<<"Etc/GMT-6"/utf8>>, 21600}, {<<"Asia/Ust-Nera"/utf8>>, 36000}, {<<"America/Cancun"/utf8>>, -18000}, {<<"America/Cuiaba"/utf8>>, -14400}, {<<"Asia/Riyadh"/utf8>>, 10800}, {<<"Etc/GMT-2"/utf8>>, 7200}, {<<"America/Tegucigalpa"/utf8>>, -21600}, {<<"Asia/Baghdad"/utf8>>, 10800}, {<<"America/Campo_Grande"/utf8>>, -14400}, {<<"EST"/utf8>>, -18000}, {<<"America/Santo_Domingo"/utf8>>, -14400}, {<<"Asia/Kathmandu"/utf8>>, 20700}, {<<"Etc/GMT+1"/utf8>>, -3600}, {<<"Asia/Bangkok"/utf8>>, 25200}, {<<"Asia/Yakutsk"/utf8>>, 32400}, {<<"Atlantic/Madeira"/utf8>>, 0}, {<<"Europe/Paris"/utf8>>, 3600}, {<<"America/Grand_Turk"/utf8>>, -18000}, {<<"Asia/Krasnoyarsk"/utf8>>, 25200}, {<<"America/Managua"/utf8>>, -21600}, {<<"MST"/utf8>>, -25200}, {<<"Etc/GMT-13"/utf8>>, 46800}, {<<"America/North_Dakota/Center"/utf8>>, -21600}, {<<"Europe/Astrakhan"/utf8>>, 14400}, {<<"Pacific/Gambier"/utf8>>, -32400}, {<<"Pacific/Fakaofo"/utf8>>, 46800}, {<<"Atlantic/Faroe"/utf8>>, 0}, {<<"Asia/Samarkand"/utf8>>, 18000}, {<<"Australia/Darwin"/utf8>>, 34200}, {<<"America/Indiana/Indianapolis"/utf8>>, -18000}, {<<"Pacific/Tarawa"/utf8>>, 43200}, {<<"Europe/Malta"/utf8>>, 3600}, {<<"America/Moncton"/utf8>>, -14400}, {<<"Pacific/Kwajalein"/utf8>>, 43200}, {<<"America/Dawson_Creek"/utf8>>, -25200}, {<<"Europe/Chisinau"/utf8>>, 7200}, {<<"Asia/Hebron"/utf8>>, 7200}, {<<"Africa/Bissau"/utf8>>, 0}, {<<"Asia/Tbilisi"/utf8>>, 14400}, {<<"Asia/Amman"/utf8>>, 10800}, {<<"Asia/Singapore"/utf8>>, 28800}, {<<"Antarctica/Casey"/utf8>>, 39600}, {<<"Europe/Riga"/utf8>>, 7200}, {<<"America/North_Dakota/Beulah"/utf8>>, -21600}, {<<"Europe/Zurich"/utf8>>, 3600}], gleam@list:key_find(_pipe, New_timezone) end of {ok, New_offset_number} -> case Value of {date_time, T, _, _, Mt} -> _pipe@1 = {date_time, T, New_offset_number, {some, New_timezone}, Mt}, {ok, _pipe@1} end; {error, nil} -> {error, nil} end. -spec get_timezone(date_time()) -> gleam@option:option(binary()). get_timezone(Value) -> {date_time, _, _, Timezone, _} = Value, Timezone. -spec parse_offset(binary()) -> {ok, integer()} | {error, nil}. parse_offset(Offset) -> gleam@bool:guard( gleam@list:contains([<<"Z"/utf8>>, <<"z"/utf8>>], Offset), {ok, 0}, fun() -> _assert_subject = gleam@regex:from_string(<<"([+-])"/utf8>>), {ok, Re} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"parse_offset"/utf8>>, line => 869}) end, gleam@result:then(case gleam@regex:split(Re, Offset) of [<<""/utf8>>, <<"+"/utf8>>, Offset@1] -> {ok, {1, Offset@1}}; [<<""/utf8>>, <<"-"/utf8>>, Offset@2] -> {ok, {-1, Offset@2}}; [_] -> {ok, {1, Offset}}; _ -> {error, nil} end, fun(_use0) -> {Sign, Offset@3} = _use0, case gleam@string:split(Offset@3, <<":"/utf8>>) of [Hour_str, Minute_str] -> gleam@result:then( gleam@int:parse(Hour_str), fun(Hour) -> gleam@result:then( gleam@int:parse(Minute_str), fun(Minute) -> {ok, ((Sign * ((Hour * 60) + Minute)) * 60) * 1000000} end ) end ); [Offset@4] -> case gleam@string:length(Offset@4) of 1 -> gleam@result:then( gleam@int:parse(Offset@4), fun(Hour@1) -> {ok, ((Sign * Hour@1) * 3600) * 1000000} end ); 2 -> gleam@result:then( gleam@int:parse(Offset@4), fun(Hour@1) -> {ok, ((Sign * Hour@1) * 3600) * 1000000} end ); 3 -> _assert_subject@1 = gleam@string:first( Offset@4 ), {ok, Hour_str@1} = case _assert_subject@1 of {ok, _} -> _assert_subject@1; _assert_fail@1 -> erlang:error( #{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail@1, module => <<"birl/time"/utf8>>, function => <<"parse_offset"/utf8>>, line => 891} ) end, Minute_str@1 = gleam@string:slice( Offset@4, 1, 2 ), gleam@result:then( gleam@int:parse(Hour_str@1), fun(Hour@2) -> gleam@result:then( gleam@int:parse(Minute_str@1), fun(Minute@1) -> {ok, ((Sign * ((Hour@2 * 60) + Minute@1)) * 60) * 1000000} end ) end ); 4 -> Hour_str@2 = gleam@string:slice( Offset@4, 0, 2 ), Minute_str@2 = gleam@string:slice( Offset@4, 2, 2 ), gleam@result:then( gleam@int:parse(Hour_str@2), fun(Hour@3) -> gleam@result:then( gleam@int:parse(Minute_str@2), fun(Minute@2) -> {ok, ((Sign * ((Hour@3 * 60) + Minute@2)) * 60) * 1000000} end ) end ); _ -> {error, nil} end; _ -> {error, nil} end end) end ). -spec set_offset(date_time(), binary()) -> {ok, date_time()} | {error, nil}. set_offset(Value, New_offset) -> gleam@result:then( parse_offset(New_offset), fun(New_offset_number) -> case Value of {date_time, T, _, Timezone, Mt} -> _pipe = {date_time, T, New_offset_number, Timezone, Mt}, {ok, _pipe} end end ). -spec generate_offset(integer()) -> {ok, binary()} | {error, nil}. generate_offset(Offset) -> gleam@bool:guard( Offset =:= 0, {ok, <<"Z"/utf8>>}, fun() -> case begin _pipe = [{Offset, micro_second}], _pipe@1 = birl@duration:new(_pipe), birl@duration:decompose(_pipe@1) end of [{Hour, hour}, {Minute, minute}] -> _pipe@10 = [case Hour > 0 of true -> gleam@string:concat( [<<"+"/utf8>>, begin _pipe@2 = Hour, _pipe@3 = gleam@int:to_string( _pipe@2 ), gleam@string:pad_left( _pipe@3, 2, <<"0"/utf8>> ) end] ); false -> gleam@string:concat( [<<"-"/utf8>>, begin _pipe@4 = Hour, _pipe@5 = gleam@int:absolute_value( _pipe@4 ), _pipe@6 = gleam@int:to_string( _pipe@5 ), gleam@string:pad_left( _pipe@6, 2, <<"0"/utf8>> ) end] ) end, begin _pipe@7 = Minute, _pipe@8 = gleam@int:absolute_value(_pipe@7), _pipe@9 = gleam@int:to_string(_pipe@8), gleam@string:pad_left(_pipe@9, 2, <<"0"/utf8>>) end], _pipe@11 = gleam@string:join(_pipe@10, <<":"/utf8>>), {ok, _pipe@11}; [{Hour@1, hour}] -> _pipe@17 = [case Hour@1 > 0 of true -> gleam@string:concat( [<<"+"/utf8>>, begin _pipe@12 = Hour@1, _pipe@13 = gleam@int:to_string( _pipe@12 ), gleam@string:pad_left( _pipe@13, 2, <<"0"/utf8>> ) end] ); false -> gleam@string:concat( [<<"-"/utf8>>, begin _pipe@14 = Hour@1, _pipe@15 = gleam@int:absolute_value( _pipe@14 ), _pipe@16 = gleam@int:to_string( _pipe@15 ), gleam@string:pad_left( _pipe@16, 2, <<"0"/utf8>> ) end] ) end, <<"00"/utf8>>], _pipe@18 = gleam@string:join(_pipe@17, <<":"/utf8>>), {ok, _pipe@18}; _ -> {error, nil} end end ). -spec get_offset(date_time()) -> binary(). get_offset(Value) -> {date_time, _, Offset, _, _} = Value, _assert_subject = generate_offset(Offset), {ok, Offset@1} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"get_offset"/utf8>>, line => 747}) end, Offset@1. -spec parse_iso_section(binary(), binary(), integer()) -> list({ok, integer()} | {error, nil}). parse_iso_section(Section, Pattern_string, Default) -> _assert_subject = gleam@regex:from_string(Pattern_string), {ok, Pattern} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"parse_iso_section"/utf8>>, line => 1017}) end, case gleam@regex:scan(Pattern, Section) of [{match, _, [{some, Major}]}] -> [gleam@int:parse(Major), {ok, Default}, {ok, Default}]; [{match, _, [{some, Major@1}, {some, Middle}]}] -> [gleam@int:parse(Major@1), gleam@int:parse(Middle), {ok, Default}]; [{match, _, [{some, Major@2}, {some, Middle@1}, {some, Minor}]}] -> [gleam@int:parse(Major@2), gleam@int:parse(Middle@1), gleam@int:parse(Minor)]; _ -> [{error, nil}] end. -spec parse_date(binary()) -> {ok, list(integer())} | {error, nil}. parse_date(Date) -> _assert_subject = gleam@regex:from_string( <<"(\\d{4})(?:-(1[0-2]|0?[0-9]))?(?:-(3[0-1]|[1-2][0-9]|0?[0-9]))?"/utf8>> ), {ok, Dash_pattern} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"parse_date"/utf8>>, line => 972}) end, _pipe = case gleam@regex:scan(Dash_pattern, Date) of [{match, _, [{some, Major}]}] -> [gleam@int:parse(Major), {ok, 1}, {ok, 1}]; [{match, _, [{some, Major@1}, {some, Middle}]}] -> [gleam@int:parse(Major@1), gleam@int:parse(Middle), {ok, 1}]; [{match, _, [{some, Major@2}, {some, Middle@1}, {some, Minor}]}] -> [gleam@int:parse(Major@2), gleam@int:parse(Middle@1), gleam@int:parse(Minor)]; _ -> parse_iso_section( Date, <<"(\\d{4})(1[0-2]|0?[0-9])?(3[0-1]|[1-2][0-9]|0?[0-9])?"/utf8>>, 1 ) end, gleam@list:try_map(_pipe, fun gleam@function:identity/1). -spec parse_time(binary()) -> {ok, list(integer())} | {error, nil}. parse_time(Time) -> _pipe = parse_iso_section( Time, <<"(2[0-3]|1[0-9]|0?[0-9])([1-5][0-9]|0?[0-9])?([1-5][0-9]|0?[0-9])?"/utf8>>, 0 ), gleam@list:try_map(_pipe, fun gleam@function:identity/1). -spec utc_now() -> date_time(). utc_now() -> Now = birl_ffi:now(), Monotonic_now = birl_ffi:monotonic_now(), {date_time, Now, 0, {some, <<"Etc/UTC"/utf8>>}, {some, Monotonic_now}}. -spec now_with_offset(binary()) -> {ok, date_time()} | {error, nil}. now_with_offset(Offset) -> gleam@result:then( parse_offset(Offset), fun(Offset@1) -> Now = birl_ffi:now(), Monotonic_now = birl_ffi:monotonic_now(), _pipe = {date_time, Now, Offset@1, none, {some, Monotonic_now}}, {ok, _pipe} end ). -spec now_with_timezone(binary()) -> {ok, date_time()} | {error, nil}. now_with_timezone(Timezone) -> case begin _pipe = [{<<"America/Santarem"/utf8>>, -10800}, {<<"America/Ciudad_Juarez"/utf8>>, -25200}, {<<"Asia/Almaty"/utf8>>, 21600}, {<<"America/Manaus"/utf8>>, -14400}, {<<"America/Adak"/utf8>>, -36000}, {<<"EST5EDT"/utf8>>, -18000}, {<<"Europe/Belgrade"/utf8>>, 3600}, {<<"Asia/Famagusta"/utf8>>, 7200}, {<<"Asia/Kabul"/utf8>>, 16200}, {<<"America/Bahia_Banderas"/utf8>>, -21600}, {<<"America/Indiana/Vevay"/utf8>>, -18000}, {<<"Atlantic/Stanley"/utf8>>, -10800}, {<<"Africa/Ndjamena"/utf8>>, 3600}, {<<"Pacific/Marquesas"/utf8>>, -34200}, {<<"Atlantic/Azores"/utf8>>, -3600}, {<<"Asia/Jerusalem"/utf8>>, 7200}, {<<"Africa/Nairobi"/utf8>>, 10800}, {<<"Asia/Tehran"/utf8>>, 12600}, {<<"America/Anchorage"/utf8>>, -32400}, {<<"America/Belem"/utf8>>, -10800}, {<<"America/Paramaribo"/utf8>>, -10800}, {<<"Etc/GMT+3"/utf8>>, -10800}, {<<"Etc/GMT+10"/utf8>>, -36000}, {<<"Asia/Novokuznetsk"/utf8>>, 25200}, {<<"Africa/Monrovia"/utf8>>, 0}, {<<"Asia/Ho_Chi_Minh"/utf8>>, 25200}, {<<"Asia/Makassar"/utf8>>, 28800}, {<<"MST7MDT"/utf8>>, -25200}, {<<"Pacific/Rarotonga"/utf8>>, -36000}, {<<"America/Ojinaga"/utf8>>, -21600}, {<<"Europe/Helsinki"/utf8>>, 7200}, {<<"Europe/Tirane"/utf8>>, 3600}, {<<"America/Noronha"/utf8>>, -7200}, {<<"Etc/GMT-4"/utf8>>, 14400}, {<<"Etc/GMT-14"/utf8>>, 50400}, {<<"Atlantic/Bermuda"/utf8>>, -14400}, {<<"America/Indiana/Winamac"/utf8>>, -18000}, {<<"America/Nuuk"/utf8>>, -7200}, {<<"America/Rankin_Inlet"/utf8>>, -21600}, {<<"Atlantic/South_Georgia"/utf8>>, -7200}, {<<"America/Tijuana"/utf8>>, -28800}, {<<"Asia/Nicosia"/utf8>>, 7200}, {<<"Pacific/Pago_Pago"/utf8>>, -39600}, {<<"America/Barbados"/utf8>>, -14400}, {<<"Asia/Tomsk"/utf8>>, 25200}, {<<"Asia/Baku"/utf8>>, 14400}, {<<"America/Argentina/Buenos_Aires"/utf8>>, -10800}, {<<"Antarctica/Mawson"/utf8>>, 18000}, {<<"Australia/Broken_Hill"/utf8>>, 34200}, {<<"America/Bogota"/utf8>>, -18000}, {<<"Asia/Macau"/utf8>>, 28800}, {<<"Pacific/Tahiti"/utf8>>, -36000}, {<<"America/Thule"/utf8>>, -14400}, {<<"Indian/Maldives"/utf8>>, 18000}, {<<"America/Whitehorse"/utf8>>, -25200}, {<<"America/Indiana/Vincennes"/utf8>>, -18000}, {<<"America/Argentina/Rio_Gallegos"/utf8>>, -10800}, {<<"America/Fort_Nelson"/utf8>>, -25200}, {<<"Asia/Shanghai"/utf8>>, 28800}, {<<"America/Nome"/utf8>>, -32400}, {<<"Asia/Choibalsan"/utf8>>, 28800}, {<<"Pacific/Palau"/utf8>>, 32400}, {<<"America/Halifax"/utf8>>, -14400}, {<<"Etc/UTC"/utf8>>, 0}, {<<"Europe/Bucharest"/utf8>>, 7200}, {<<"Antarctica/Davis"/utf8>>, 25200}, {<<"Etc/GMT+4"/utf8>>, -14400}, {<<"Asia/Jakarta"/utf8>>, 25200}, {<<"Africa/Sao_Tome"/utf8>>, 0}, {<<"Asia/Qyzylorda"/utf8>>, 18000}, {<<"Asia/Hovd"/utf8>>, 25200}, {<<"Africa/Khartoum"/utf8>>, 7200}, {<<"Antarctica/Troll"/utf8>>, 0}, {<<"Asia/Anadyr"/utf8>>, 43200}, {<<"HST"/utf8>>, -36000}, {<<"CST6CDT"/utf8>>, -21600}, {<<"America/Glace_Bay"/utf8>>, -14400}, {<<"Africa/Tripoli"/utf8>>, 7200}, {<<"Europe/Berlin"/utf8>>, 3600}, {<<"Europe/Tallinn"/utf8>>, 7200}, {<<"America/La_Paz"/utf8>>, -14400}, {<<"America/Mazatlan"/utf8>>, -25200}, {<<"Pacific/Nauru"/utf8>>, 43200}, {<<"Asia/Sakhalin"/utf8>>, 39600}, {<<"America/Puerto_Rico"/utf8>>, -14400}, {<<"Pacific/Norfolk"/utf8>>, 39600}, {<<"America/Danmarkshavn"/utf8>>, 0}, {<<"Pacific/Auckland"/utf8>>, 43200}, {<<"America/Argentina/Catamarca"/utf8>>, -10800}, {<<"America/Porto_Velho"/utf8>>, -14400}, {<<"America/Cayenne"/utf8>>, -10800}, {<<"Etc/GMT-5"/utf8>>, 18000}, {<<"Pacific/Guadalcanal"/utf8>>, 39600}, {<<"America/Indiana/Tell_City"/utf8>>, -21600}, {<<"Asia/Kamchatka"/utf8>>, 43200}, {<<"Europe/Vilnius"/utf8>>, 7200}, {<<"Asia/Bishkek"/utf8>>, 21600}, {<<"America/New_York"/utf8>>, -18000}, {<<"America/Belize"/utf8>>, -21600}, {<<"Africa/Algiers"/utf8>>, 3600}, {<<"Asia/Yerevan"/utf8>>, 14400}, {<<"America/Jamaica"/utf8>>, -18000}, {<<"Europe/Madrid"/utf8>>, 3600}, {<<"Asia/Aqtau"/utf8>>, 18000}, {<<"Asia/Vladivostok"/utf8>>, 36000}, {<<"Europe/Kirov"/utf8>>, 10800}, {<<"Asia/Chita"/utf8>>, 32400}, {<<"WET"/utf8>>, 0}, {<<"Australia/Perth"/utf8>>, 28800}, {<<"America/Argentina/San_Juan"/utf8>>, -10800}, {<<"Asia/Yangon"/utf8>>, 23400}, {<<"America/Goose_Bay"/utf8>>, -14400}, {<<"Asia/Gaza"/utf8>>, 7200}, {<<"America/Chicago"/utf8>>, -21600}, {<<"Africa/Cairo"/utf8>>, 7200}, {<<"Asia/Seoul"/utf8>>, 32400}, {<<"America/Scoresbysund"/utf8>>, -3600}, {<<"Europe/Gibraltar"/utf8>>, 3600}, {<<"Europe/Volgograd"/utf8>>, 10800}, {<<"Asia/Urumqi"/utf8>>, 21600}, {<<"Asia/Irkutsk"/utf8>>, 28800}, {<<"America/Resolute"/utf8>>, -21600}, {<<"America/Martinique"/utf8>>, -14400}, {<<"America/Asuncion"/utf8>>, -14400}, {<<"Africa/El_Aaiun"/utf8>>, 3600}, {<<"America/Dawson"/utf8>>, -25200}, {<<"America/Panama"/utf8>>, -18000}, {<<"Asia/Novosibirsk"/utf8>>, 25200}, {<<"Antarctica/Palmer"/utf8>>, -10800}, {<<"Etc/GMT-8"/utf8>>, 28800}, {<<"America/Juneau"/utf8>>, -32400}, {<<"America/Guayaquil"/utf8>>, -18000}, {<<"Asia/Ulaanbaatar"/utf8>>, 28800}, {<<"Asia/Taipei"/utf8>>, 28800}, {<<"Pacific/Chatham"/utf8>>, 45900}, {<<"Etc/GMT+2"/utf8>>, -7200}, {<<"Europe/Budapest"/utf8>>, 3600}, {<<"America/Havana"/utf8>>, -18000}, {<<"Etc/GMT+12"/utf8>>, -43200}, {<<"Africa/Tunis"/utf8>>, 3600}, {<<"Asia/Kolkata"/utf8>>, 19800}, {<<"America/Denver"/utf8>>, -25200}, {<<"America/Menominee"/utf8>>, -21600}, {<<"Asia/Dhaka"/utf8>>, 21600}, {<<"Asia/Hong_Kong"/utf8>>, 28800}, {<<"Asia/Magadan"/utf8>>, 39600}, {<<"Asia/Pontianak"/utf8>>, 25200}, {<<"Asia/Dubai"/utf8>>, 14400}, {<<"America/Indiana/Petersburg"/utf8>>, -18000}, {<<"America/Winnipeg"/utf8>>, -21600}, {<<"America/Vancouver"/utf8>>, -28800}, {<<"America/Detroit"/utf8>>, -18000}, {<<"America/Bahia"/utf8>>, -10800}, {<<"Pacific/Galapagos"/utf8>>, -21600}, {<<"Africa/Windhoek"/utf8>>, 7200}, {<<"Pacific/Kiritimati"/utf8>>, 50400}, {<<"Etc/GMT-1"/utf8>>, 3600}, {<<"Europe/Andorra"/utf8>>, 3600}, {<<"America/Merida"/utf8>>, -21600}, {<<"Africa/Lagos"/utf8>>, 3600}, {<<"America/Mexico_City"/utf8>>, -21600}, {<<"Asia/Yekaterinburg"/utf8>>, 18000}, {<<"America/Argentina/Cordoba"/utf8>>, -10800}, {<<"Asia/Kuching"/utf8>>, 28800}, {<<"Asia/Manila"/utf8>>, 28800}, {<<"Australia/Lindeman"/utf8>>, 36000}, {<<"Asia/Dushanbe"/utf8>>, 18000}, {<<"Pacific/Pitcairn"/utf8>>, -28800}, {<<"Etc/GMT-12"/utf8>>, 43200}, {<<"America/Punta_Arenas"/utf8>>, -10800}, {<<"America/Maceio"/utf8>>, -10800}, {<<"America/Guyana"/utf8>>, -14400}, {<<"Asia/Pyongyang"/utf8>>, 32400}, {<<"Antarctica/Macquarie"/utf8>>, 36000}, {<<"Pacific/Kosrae"/utf8>>, 39600}, {<<"Africa/Juba"/utf8>>, 7200}, {<<"Indian/Mauritius"/utf8>>, 14400}, {<<"Antarctica/Rothera"/utf8>>, -10800}, {<<"Asia/Colombo"/utf8>>, 19800}, {<<"Asia/Barnaul"/utf8>>, 25200}, {<<"Europe/London"/utf8>>, 0}, {<<"Africa/Ceuta"/utf8>>, 3600}, {<<"America/Guatemala"/utf8>>, -21600}, {<<"Europe/Moscow"/utf8>>, 10800}, {<<"America/Indiana/Knox"/utf8>>, -21600}, {<<"America/Toronto"/utf8>>, -18000}, {<<"Australia/Sydney"/utf8>>, 36000}, {<<"Pacific/Kanton"/utf8>>, 46800}, {<<"Asia/Omsk"/utf8>>, 21600}, {<<"Etc/GMT+6"/utf8>>, -21600}, {<<"Europe/Samara"/utf8>>, 14400}, {<<"America/Kentucky/Louisville"/utf8>>, -18000}, {<<"America/Iqaluit"/utf8>>, -18000}, {<<"CET"/utf8>>, 3600}, {<<"Europe/Saratov"/utf8>>, 14400}, {<<"America/Argentina/Ushuaia"/utf8>>, -10800}, {<<"America/Regina"/utf8>>, -21600}, {<<"Etc/GMT-9"/utf8>>, 32400}, {<<"Etc/GMT+11"/utf8>>, -39600}, {<<"America/Boa_Vista"/utf8>>, -14400}, {<<"MET"/utf8>>, 3600}, {<<"Australia/Adelaide"/utf8>>, 34200}, {<<"EET"/utf8>>, 7200}, {<<"Africa/Casablanca"/utf8>>, 3600}, {<<"America/Chihuahua"/utf8>>, -21600}, {<<"America/Indiana/Marengo"/utf8>>, -18000}, {<<"America/Cambridge_Bay"/utf8>>, -25200}, {<<"Etc/GMT-10"/utf8>>, 36000}, {<<"Australia/Eucla"/utf8>>, 31500}, {<<"Asia/Srednekolymsk"/utf8>>, 39600}, {<<"Europe/Rome"/utf8>>, 3600}, {<<"America/Matamoros"/utf8>>, -21600}, {<<"America/Miquelon"/utf8>>, -10800}, {<<"Pacific/Honolulu"/utf8>>, -36000}, {<<"America/Eirunepe"/utf8>>, -18000}, {<<"Europe/Dublin"/utf8>>, 3600}, {<<"America/Santiago"/utf8>>, -14400}, {<<"America/Argentina/San_Luis"/utf8>>, -10800}, {<<"Asia/Beirut"/utf8>>, 7200}, {<<"Pacific/Fiji"/utf8>>, 43200}, {<<"America/Montevideo"/utf8>>, -10800}, {<<"Asia/Jayapura"/utf8>>, 32400}, {<<"Asia/Qostanay"/utf8>>, 21600}, {<<"Europe/Warsaw"/utf8>>, 3600}, {<<"Asia/Khandyga"/utf8>>, 32400}, {<<"America/Costa_Rica"/utf8>>, -21600}, {<<"America/Sao_Paulo"/utf8>>, -10800}, {<<"America/Argentina/Mendoza"/utf8>>, -10800}, {<<"America/Sitka"/utf8>>, -32400}, {<<"America/Kentucky/Monticello"/utf8>>, -18000}, {<<"America/Argentina/Tucuman"/utf8>>, -10800}, {<<"America/Fortaleza"/utf8>>, -10800}, {<<"America/Araguaina"/utf8>>, -10800}, {<<"America/Monterrey"/utf8>>, -21600}, {<<"Atlantic/Canary"/utf8>>, 0}, {<<"Asia/Atyrau"/utf8>>, 18000}, {<<"Australia/Lord_Howe"/utf8>>, 37800}, {<<"Etc/GMT-3"/utf8>>, 10800}, {<<"Pacific/Apia"/utf8>>, 46800}, {<<"Australia/Hobart"/utf8>>, 36000}, {<<"Europe/Prague"/utf8>>, 3600}, {<<"Asia/Aqtobe"/utf8>>, 18000}, {<<"Africa/Maputo"/utf8>>, 7200}, {<<"Asia/Oral"/utf8>>, 18000}, {<<"Europe/Athens"/utf8>>, 7200}, {<<"Etc/GMT+5"/utf8>>, -18000}, {<<"Europe/Simferopol"/utf8>>, 10800}, {<<"Europe/Brussels"/utf8>>, 3600}, {<<"America/Port-au-Prince"/utf8>>, -18000}, {<<"Etc/GMT-11"/utf8>>, 39600}, {<<"Etc/GMT+9"/utf8>>, -32400}, {<<"America/Argentina/Salta"/utf8>>, -10800}, {<<"Pacific/Niue"/utf8>>, -39600}, {<<"America/Los_Angeles"/utf8>>, -28800}, {<<"Australia/Brisbane"/utf8>>, 36000}, {<<"America/Boise"/utf8>>, -25200}, {<<"America/Edmonton"/utf8>>, -25200}, {<<"Pacific/Port_Moresby"/utf8>>, 36000}, {<<"Pacific/Bougainville"/utf8>>, 39600}, {<<"Asia/Tokyo"/utf8>>, 32400}, {<<"America/Yakutat"/utf8>>, -32400}, {<<"Pacific/Tongatapu"/utf8>>, 46800}, {<<"America/Inuvik"/utf8>>, -25200}, {<<"Indian/Chagos"/utf8>>, 21600}, {<<"America/Caracas"/utf8>>, -14400}, {<<"PST8PDT"/utf8>>, -28800}, {<<"Europe/Lisbon"/utf8>>, 0}, {<<"Asia/Damascus"/utf8>>, 10800}, {<<"Pacific/Efate"/utf8>>, 39600}, {<<"Asia/Karachi"/utf8>>, 18000}, {<<"America/Argentina/La_Rioja"/utf8>>, -10800}, {<<"Africa/Johannesburg"/utf8>>, 7200}, {<<"Australia/Melbourne"/utf8>>, 36000}, {<<"Etc/GMT"/utf8>>, 0}, {<<"Africa/Abidjan"/utf8>>, 0}, {<<"Asia/Dili"/utf8>>, 32400}, {<<"America/Lima"/utf8>>, -18000}, {<<"Europe/Istanbul"/utf8>>, 10800}, {<<"Asia/Ashgabat"/utf8>>, 18000}, {<<"America/Rio_Branco"/utf8>>, -18000}, {<<"America/El_Salvador"/utf8>>, -21600}, {<<"Pacific/Guam"/utf8>>, 36000}, {<<"America/Hermosillo"/utf8>>, -25200}, {<<"America/Metlakatla"/utf8>>, -32400}, {<<"Etc/GMT-7"/utf8>>, 25200}, {<<"Etc/GMT+7"/utf8>>, -25200}, {<<"Europe/Vienna"/utf8>>, 3600}, {<<"Europe/Kaliningrad"/utf8>>, 7200}, {<<"America/St_Johns"/utf8>>, -12600}, {<<"America/North_Dakota/New_Salem"/utf8>>, -21600}, {<<"Asia/Qatar"/utf8>>, 10800}, {<<"America/Recife"/utf8>>, -10800}, {<<"Asia/Thimphu"/utf8>>, 21600}, {<<"Pacific/Noumea"/utf8>>, 39600}, {<<"Europe/Sofia"/utf8>>, 7200}, {<<"Atlantic/Cape_Verde"/utf8>>, -3600}, {<<"Europe/Minsk"/utf8>>, 10800}, {<<"America/Swift_Current"/utf8>>, -21600}, {<<"Europe/Ulyanovsk"/utf8>>, 14400}, {<<"Europe/Kyiv"/utf8>>, 7200}, {<<"Etc/GMT+8"/utf8>>, -28800}, {<<"America/Phoenix"/utf8>>, -25200}, {<<"Pacific/Easter"/utf8>>, -21600}, {<<"America/Argentina/Jujuy"/utf8>>, -10800}, {<<"Asia/Tashkent"/utf8>>, 18000}, {<<"Etc/GMT-6"/utf8>>, 21600}, {<<"Asia/Ust-Nera"/utf8>>, 36000}, {<<"America/Cancun"/utf8>>, -18000}, {<<"America/Cuiaba"/utf8>>, -14400}, {<<"Asia/Riyadh"/utf8>>, 10800}, {<<"Etc/GMT-2"/utf8>>, 7200}, {<<"America/Tegucigalpa"/utf8>>, -21600}, {<<"Asia/Baghdad"/utf8>>, 10800}, {<<"America/Campo_Grande"/utf8>>, -14400}, {<<"EST"/utf8>>, -18000}, {<<"America/Santo_Domingo"/utf8>>, -14400}, {<<"Asia/Kathmandu"/utf8>>, 20700}, {<<"Etc/GMT+1"/utf8>>, -3600}, {<<"Asia/Bangkok"/utf8>>, 25200}, {<<"Asia/Yakutsk"/utf8>>, 32400}, {<<"Atlantic/Madeira"/utf8>>, 0}, {<<"Europe/Paris"/utf8>>, 3600}, {<<"America/Grand_Turk"/utf8>>, -18000}, {<<"Asia/Krasnoyarsk"/utf8>>, 25200}, {<<"America/Managua"/utf8>>, -21600}, {<<"MST"/utf8>>, -25200}, {<<"Etc/GMT-13"/utf8>>, 46800}, {<<"America/North_Dakota/Center"/utf8>>, -21600}, {<<"Europe/Astrakhan"/utf8>>, 14400}, {<<"Pacific/Gambier"/utf8>>, -32400}, {<<"Pacific/Fakaofo"/utf8>>, 46800}, {<<"Atlantic/Faroe"/utf8>>, 0}, {<<"Asia/Samarkand"/utf8>>, 18000}, {<<"Australia/Darwin"/utf8>>, 34200}, {<<"America/Indiana/Indianapolis"/utf8>>, -18000}, {<<"Pacific/Tarawa"/utf8>>, 43200}, {<<"Europe/Malta"/utf8>>, 3600}, {<<"America/Moncton"/utf8>>, -14400}, {<<"Pacific/Kwajalein"/utf8>>, 43200}, {<<"America/Dawson_Creek"/utf8>>, -25200}, {<<"Europe/Chisinau"/utf8>>, 7200}, {<<"Asia/Hebron"/utf8>>, 7200}, {<<"Africa/Bissau"/utf8>>, 0}, {<<"Asia/Tbilisi"/utf8>>, 14400}, {<<"Asia/Amman"/utf8>>, 10800}, {<<"Asia/Singapore"/utf8>>, 28800}, {<<"Antarctica/Casey"/utf8>>, 39600}, {<<"Europe/Riga"/utf8>>, 7200}, {<<"America/North_Dakota/Beulah"/utf8>>, -21600}, {<<"Europe/Zurich"/utf8>>, 3600}], gleam@list:key_find(_pipe, Timezone) end of {ok, Offset} -> Now = birl_ffi:now(), Monotonic_now = birl_ffi:monotonic_now(), _pipe@1 = {date_time, Now, Offset * 1000000, {some, Timezone}, {some, Monotonic_now}}, {ok, _pipe@1}; {error, nil} -> {error, nil} end. -spec monotonic_now() -> integer(). monotonic_now() -> birl_ffi:monotonic_now(). -spec to_parts(date_time()) -> {{integer(), integer(), integer()}, {integer(), integer(), integer(), integer()}, binary()}. to_parts(Value) -> case Value of {date_time, T, O, _, _} -> {Date, Time} = birl_ffi:to_parts(T, O), _assert_subject = generate_offset(O), {ok, Offset} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"to_parts"/utf8>>, line => 850}) end, {Date, Time, Offset} end. -spec to_iso8601(date_time()) -> binary(). to_iso8601(Value) -> {{Year, Month, Day}, {Hour, Minute, Second, Milli_second}, Offset} = to_parts( Value ), <<<<<<<<<<<<<<<<<<<<<<<<<<(gleam@int:to_string(Year))/binary, "-"/utf8>>/binary, (begin _pipe = Month, _pipe@1 = gleam@int:to_string( _pipe ), gleam@string:pad_left( _pipe@1, 2, <<"0"/utf8>> ) end)/binary>>/binary, "-"/utf8>>/binary, (begin _pipe@2 = Day, _pipe@3 = gleam@int:to_string( _pipe@2 ), gleam@string:pad_left( _pipe@3, 2, <<"0"/utf8>> ) end)/binary>>/binary, "T"/utf8>>/binary, (begin _pipe@4 = Hour, _pipe@5 = gleam@int:to_string(_pipe@4), gleam@string:pad_left( _pipe@5, 2, <<"0"/utf8>> ) end)/binary>>/binary, ":"/utf8>>/binary, (begin _pipe@6 = Minute, _pipe@7 = gleam@int:to_string(_pipe@6), gleam@string:pad_left(_pipe@7, 2, <<"0"/utf8>>) end)/binary>>/binary, ":"/utf8>>/binary, (begin _pipe@8 = Second, _pipe@9 = gleam@int:to_string(_pipe@8), gleam@string:pad_left(_pipe@9, 2, <<"0"/utf8>>) end)/binary>>/binary, "."/utf8>>/binary, (begin _pipe@10 = Milli_second, _pipe@11 = gleam@int:to_string(_pipe@10), gleam@string:pad_left(_pipe@11, 3, <<"0"/utf8>>) end)/binary>>/binary, Offset/binary>>. -spec to_naive(date_time()) -> binary(). to_naive(Value) -> {{Year, Month, Day}, {Hour, Minute, Second, Milli_second}, _} = to_parts( Value ), <<<<<<<<<<<<<<<<<<<<<<<<(gleam@int:to_string(Year))/binary, "-"/utf8>>/binary, (begin _pipe = Month, _pipe@1 = gleam@int:to_string( _pipe ), gleam@string:pad_left( _pipe@1, 2, <<"0"/utf8>> ) end)/binary>>/binary, "-"/utf8>>/binary, (begin _pipe@2 = Day, _pipe@3 = gleam@int:to_string( _pipe@2 ), gleam@string:pad_left( _pipe@3, 2, <<"0"/utf8>> ) end)/binary>>/binary, "T"/utf8>>/binary, (begin _pipe@4 = Hour, _pipe@5 = gleam@int:to_string(_pipe@4), gleam@string:pad_left( _pipe@5, 2, <<"0"/utf8>> ) end)/binary>>/binary, ":"/utf8>>/binary, (begin _pipe@6 = Minute, _pipe@7 = gleam@int:to_string(_pipe@6), gleam@string:pad_left(_pipe@7, 2, <<"0"/utf8>>) end)/binary>>/binary, ":"/utf8>>/binary, (begin _pipe@8 = Second, _pipe@9 = gleam@int:to_string(_pipe@8), gleam@string:pad_left(_pipe@9, 2, <<"0"/utf8>>) end)/binary>>/binary, "."/utf8>>/binary, (begin _pipe@10 = Milli_second, _pipe@11 = gleam@int:to_string(_pipe@10), gleam@string:pad_left(_pipe@11, 3, <<"0"/utf8>>) end)/binary>>. -spec month(date_time()) -> month(). month(Value) -> {{_, Month, _}, _, _} = to_parts(Value), _assert_subject = gleam@list:at( [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec], Month - 1 ), {ok, Month@1} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"month"/utf8>>, line => 660}) end, Month@1. -spec string_month(date_time()) -> binary(). string_month(Value) -> Month = month(Value), _assert_subject = gleam@list:key_find( [{jan, {<<"January"/utf8>>, <<"Jan"/utf8>>}}, {feb, {<<"February"/utf8>>, <<"Feb"/utf8>>}}, {mar, {<<"March"/utf8>>, <<"Mar"/utf8>>}}, {apr, {<<"April"/utf8>>, <<"Apr"/utf8>>}}, {may, {<<"May"/utf8>>, <<"May"/utf8>>}}, {jun, {<<"June"/utf8>>, <<"Jun"/utf8>>}}, {jul, {<<"July"/utf8>>, <<"Jul"/utf8>>}}, {aug, {<<"August"/utf8>>, <<"Aug"/utf8>>}}, {sep, {<<"September"/utf8>>, <<"Sep"/utf8>>}}, {oct, {<<"October"/utf8>>, <<"Oct"/utf8>>}}, {nov, {<<"November"/utf8>>, <<"Nov"/utf8>>}}, {dec, {<<"December"/utf8>>, <<"Dec"/utf8>>}}], Month ), {ok, {Month@1, _}} = case _assert_subject of {ok, {_, _}} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"string_month"/utf8>>, line => 666}) end, Month@1. -spec short_string_month(date_time()) -> binary(). short_string_month(Value) -> Month = month(Value), _assert_subject = gleam@list:key_find( [{jan, {<<"January"/utf8>>, <<"Jan"/utf8>>}}, {feb, {<<"February"/utf8>>, <<"Feb"/utf8>>}}, {mar, {<<"March"/utf8>>, <<"Mar"/utf8>>}}, {apr, {<<"April"/utf8>>, <<"Apr"/utf8>>}}, {may, {<<"May"/utf8>>, <<"May"/utf8>>}}, {jun, {<<"June"/utf8>>, <<"Jun"/utf8>>}}, {jul, {<<"July"/utf8>>, <<"Jul"/utf8>>}}, {aug, {<<"August"/utf8>>, <<"Aug"/utf8>>}}, {sep, {<<"September"/utf8>>, <<"Sep"/utf8>>}}, {oct, {<<"October"/utf8>>, <<"Oct"/utf8>>}}, {nov, {<<"November"/utf8>>, <<"Nov"/utf8>>}}, {dec, {<<"December"/utf8>>, <<"Dec"/utf8>>}}], Month ), {ok, {_, Month@1}} = case _assert_subject of {ok, {_, _}} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"short_string_month"/utf8>>, line => 672}) end, Month@1. -spec get_date(date_time()) -> date(). get_date(Value) -> {{Year, Month, Day}, _, _} = to_parts(Value), {date, Year, Month, Day}. -spec get_time(date_time()) -> time(). get_time(Value) -> {_, {Hour, Minute, Second, Milli_second}, _} = to_parts(Value), {time, Hour, Minute, Second, Milli_second}. -spec to_erlang_datetime(date_time()) -> {{integer(), integer(), integer()}, {integer(), integer(), integer()}}. to_erlang_datetime(Value) -> {Date, {Hour, Minute, Second, _}, _} = to_parts(Value), {Date, {Hour, Minute, Second}}. -spec to_erlang_universal_datetime(date_time()) -> {{integer(), integer(), integer()}, {integer(), integer(), integer()}}. to_erlang_universal_datetime(Value) -> _assert_subject = set_offset(Value, <<"Z"/utf8>>), {ok, Value@1} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"to_erlang_universal_datetime"/utf8>>, line => 790}) end, {Date, {Hour, Minute, Second, _}, _} = to_parts(Value@1), {Date, {Hour, Minute, Second}}. -spec from_parts( {integer(), integer(), integer()}, {integer(), integer(), integer(), integer()}, binary() ) -> {ok, date_time()} | {error, nil}. from_parts(Date, Time, Offset) -> gleam@result:then( parse_offset(Offset), fun(Offset_number) -> _pipe = birl_ffi:from_parts({Date, Time}, Offset_number), _pipe@1 = {date_time, _pipe, Offset_number, none, none}, {ok, _pipe@1} end ). -spec from_iso8601(binary()) -> {ok, date_time()} | {error, nil}. from_iso8601(Value) -> _assert_subject = gleam@regex:from_string(<<"(.*)([+|\\-].*)"/utf8>>), {ok, Offset_pattern} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"from_iso8601"/utf8>>, line => 165}) end, Value@1 = gleam@string:trim(Value), {Date_string@2, Offsetted_time_string@1} = case gleam@string:split( Value@1, <<"T"/utf8>> ) of [Date_string] -> {Date_string, <<"00"/utf8>>}; [Date_string@1, Offsetted_time_string] -> {Date_string@1, Offsetted_time_string} end, Date_string@3 = gleam@string:trim(Date_string@2), Offsetted_time_string@2 = gleam@string:trim(Offsetted_time_string@1), {Time_string@1, Offset_string@1} = case gleam@string:ends_with( Offsetted_time_string@2, <<"Z"/utf8>> ) orelse gleam@string:ends_with(Offsetted_time_string@2, <<"z"/utf8>>) of true -> {gleam@string:drop_right(Offsetted_time_string@2, 1), <<"+00:00"/utf8>>}; false -> case gleam@regex:scan(Offset_pattern, Offsetted_time_string@2) of [{match, _, [{some, Time_string}, {some, Offset_string}]}] -> {Time_string, Offset_string}; [] -> Local_offset_in_minutes = birl_ffi:local_offset(), _assert_subject@1 = generate_offset( Local_offset_in_minutes * 60000000 ), {ok, Local_offset_string} = case _assert_subject@1 of {ok, _} -> _assert_subject@1; _assert_fail@1 -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail@1, module => <<"birl/time"/utf8>>, function => <<"from_iso8601"/utf8>>, line => 194}) end, {Offsetted_time_string@2, Local_offset_string} end end, Time_string@2 = gleam@string:replace( Time_string@1, <<":"/utf8>>, <<""/utf8>> ), {Time_string@5, Milli_seconds_result} = case gleam@string:split( Time_string@2, <<"."/utf8>> ) of [Time_string@3] -> {Time_string@3, {ok, 0}}; [Time_string@4, Milli_seconds_string] -> {Time_string@4, gleam@int:parse(Milli_seconds_string)} end, case Milli_seconds_result of {ok, Milli_seconds} -> gleam@result:then( parse_date(Date_string@3), fun(_use0) -> [Year, Month, Day] = _use0, gleam@result:then( parse_time(Time_string@5), fun(_use0@1) -> [Hour, Minute, Second] = _use0@1, case from_parts( {Year, Month, Day}, {Hour, Minute, Second, Milli_seconds}, Offset_string@1 ) of {ok, {date_time, Timestamp, Offset, none, none}} -> {ok, {date_time, Timestamp, Offset, none, none}}; {error, nil} -> {error, nil} end end ) end ); {error, nil} -> {error, nil} end. -spec from_naive(binary()) -> {ok, date_time()} | {error, nil}. from_naive(Value) -> Value@1 = gleam@string:trim(Value), {Date_string@2, Time_string@1} = case gleam@string:split( Value@1, <<"T"/utf8>> ) of [Date_string] -> {Date_string, <<"00"/utf8>>}; [Date_string@1, Time_string] -> {Date_string@1, Time_string} end, Date_string@3 = gleam@string:trim(Date_string@2), Time_string@2 = gleam@string:trim(Time_string@1), Time_string@3 = gleam@string:replace( Time_string@2, <<":"/utf8>>, <<""/utf8>> ), {Time_string@6, Milli_seconds_result} = case gleam@string:split( Time_string@3, <<"."/utf8>> ) of [Time_string@4] -> {Time_string@4, {ok, 0}}; [Time_string@5, Milli_seconds_string] -> {Time_string@5, gleam@int:parse(Milli_seconds_string)} end, case Milli_seconds_result of {ok, Milli_seconds} -> gleam@result:then( parse_date(Date_string@3), fun(_use0) -> [Year, Month, Day] = _use0, gleam@result:then( parse_time(Time_string@6), fun(_use0@1) -> [Hour, Minute, Second] = _use0@1, case from_parts( {Year, Month, Day}, {Hour, Minute, Second, Milli_seconds}, <<"Z"/utf8>> ) of {ok, {date_time, Timestamp, Offset, none, none}} -> {ok, {date_time, Timestamp, Offset, none, none}}; {error, nil} -> {error, nil} end end ) end ); {error, nil} -> {error, nil} end. -spec set_date(date_time(), date()) -> date_time(). set_date(Value, Date) -> {_, Time, Offset} = to_parts(Value), {date, Year, Month, Day} = Date, _assert_subject = from_parts({Year, Month, Day}, Time, Offset), {ok, New_value} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"set_date"/utf8>>, line => 754}) end, New_value. -spec set_time(date_time(), time()) -> date_time(). set_time(Value, Time) -> {Date, _, Offset} = to_parts(Value), {time, Hour, Minute, Second, Milli_second} = Time, _assert_subject = from_parts( Date, {Hour, Minute, Second, Milli_second}, Offset ), {ok, New_value} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"set_time"/utf8>>, line => 766}) end, New_value. -spec from_erlang_universal_datetime( {{integer(), integer(), integer()}, {integer(), integer(), integer()}} ) -> date_time(). from_erlang_universal_datetime(Erlang_datetime) -> {Date, Time} = Erlang_datetime, _assert_subject = begin _pipe = {date_time, 0, 0, none, none}, _pipe@1 = set_date( _pipe, {date, erlang:element(1, Date), erlang:element(2, Date), erlang:element(3, Date)} ), _pipe@2 = set_time( _pipe@1, {time, erlang:element(1, Time), erlang:element(2, Time), erlang:element(3, Time), 0} ), set_timezone(_pipe@2, <<"Etc/UTC"/utf8>>) end, {ok, New_value} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"from_erlang_universal_datetime"/utf8>>, line => 836}) end, New_value. -spec weekday(date_time()) -> weekday(). weekday(Value) -> case Value of {date_time, T, O, _, _} -> _assert_subject = gleam@list:at( [mon, tue, wed, thu, fri, sat, sun], birl_ffi:weekday(T, O) ), {ok, Weekday} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"weekday"/utf8>>, line => 640}) end, Weekday end. -spec string_weekday(date_time()) -> binary(). string_weekday(Value) -> Weekday = weekday(Value), _assert_subject = gleam@list:key_find( [{mon, {<<"Monday"/utf8>>, <<"Mon"/utf8>>}}, {tue, {<<"Tuesday"/utf8>>, <<"Tue"/utf8>>}}, {wed, {<<"Wednesday"/utf8>>, <<"Wed"/utf8>>}}, {thu, {<<"Thursday"/utf8>>, <<"Thu"/utf8>>}}, {fri, {<<"Friday"/utf8>>, <<"Fri"/utf8>>}}, {sat, {<<"Saturday"/utf8>>, <<"Sat"/utf8>>}}, {sun, {<<"Sunday"/utf8>>, <<"Sun"/utf8>>}}], Weekday ), {ok, {Weekday@1, _}} = case _assert_subject of {ok, {_, _}} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"string_weekday"/utf8>>, line => 648}) end, Weekday@1. -spec short_string_weekday(date_time()) -> binary(). short_string_weekday(Value) -> Weekday = weekday(Value), _assert_subject = gleam@list:key_find( [{mon, {<<"Monday"/utf8>>, <<"Mon"/utf8>>}}, {tue, {<<"Tuesday"/utf8>>, <<"Tue"/utf8>>}}, {wed, {<<"Wednesday"/utf8>>, <<"Wed"/utf8>>}}, {thu, {<<"Thursday"/utf8>>, <<"Thu"/utf8>>}}, {fri, {<<"Friday"/utf8>>, <<"Fri"/utf8>>}}, {sat, {<<"Saturday"/utf8>>, <<"Sat"/utf8>>}}, {sun, {<<"Sunday"/utf8>>, <<"Sun"/utf8>>}}], Weekday ), {ok, {_, Weekday@1}} = case _assert_subject of {ok, {_, _}} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"short_string_weekday"/utf8>>, line => 654}) end, Weekday@1. -spec to_http(date_time()) -> binary(). to_http(Value) -> _assert_subject = set_offset(Value, <<"Z"/utf8>>), {ok, Value@1} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"to_http"/utf8>>, line => 316}) end, {{Year, _, Day}, {Hour, Minute, Second, _}, _} = to_parts(Value@1), Short_weekday = short_string_weekday(Value@1), Short_month = short_string_month(Value@1), <<<<<<<<<<<<<<<<<<<<<<<<<>/binary, (begin _pipe = Day, _pipe@1 = gleam@int:to_string( _pipe ), gleam@string:pad_left( _pipe@1, 2, <<"0"/utf8>> ) end)/binary>>/binary, " "/utf8>>/binary, Short_month/binary>>/binary, " "/utf8>>/binary, (gleam@int:to_string(Year))/binary>>/binary, " "/utf8>>/binary, (begin _pipe@2 = Hour, _pipe@3 = gleam@int:to_string(_pipe@2), gleam@string:pad_left(_pipe@3, 2, <<"0"/utf8>>) end)/binary>>/binary, ":"/utf8>>/binary, (begin _pipe@4 = Minute, _pipe@5 = gleam@int:to_string(_pipe@4), gleam@string:pad_left(_pipe@5, 2, <<"0"/utf8>>) end)/binary>>/binary, ":"/utf8>>/binary, (begin _pipe@6 = Second, _pipe@7 = gleam@int:to_string(_pipe@6), gleam@string:pad_left(_pipe@7, 2, <<"0"/utf8>>) end)/binary>>/binary, " GMT"/utf8>>. -spec to_http_with_offset(date_time()) -> binary(). to_http_with_offset(Value) -> {{Year, _, Day}, {Hour, Minute, Second, _}, Offset} = to_parts(Value), Short_weekday = short_string_weekday(Value), Short_month = short_string_month(Value), Offset@1 = case Offset of <<"Z"/utf8>> -> <<"GMT"/utf8>>; _ -> Offset end, <<<<<<<<<<<<<<<<<<<<<<<<<<<>/binary, (begin _pipe = Day, _pipe@1 = gleam@int:to_string( _pipe ), gleam@string:pad_left( _pipe@1, 2, <<"0"/utf8>> ) end)/binary>>/binary, " "/utf8>>/binary, Short_month/binary>>/binary, " "/utf8>>/binary, (gleam@int:to_string(Year))/binary>>/binary, " "/utf8>>/binary, (begin _pipe@2 = Hour, _pipe@3 = gleam@int:to_string(_pipe@2), gleam@string:pad_left( _pipe@3, 2, <<"0"/utf8>> ) end)/binary>>/binary, ":"/utf8>>/binary, (begin _pipe@4 = Minute, _pipe@5 = gleam@int:to_string(_pipe@4), gleam@string:pad_left(_pipe@5, 2, <<"0"/utf8>>) end)/binary>>/binary, ":"/utf8>>/binary, (begin _pipe@6 = Second, _pipe@7 = gleam@int:to_string(_pipe@6), gleam@string:pad_left(_pipe@7, 2, <<"0"/utf8>>) end)/binary>>/binary, " "/utf8>>/binary, Offset@1/binary>>. -spec from_http(binary()) -> {ok, date_time()} | {error, nil}. from_http(Value) -> Value@1 = gleam@string:trim(Value), [Weekday, Rest] = gleam@string:split(Value@1, <<","/utf8>>), gleam@bool:guard( not gleam@list:any( [{mon, {<<"Monday"/utf8>>, <<"Mon"/utf8>>}}, {tue, {<<"Tuesday"/utf8>>, <<"Tue"/utf8>>}}, {wed, {<<"Wednesday"/utf8>>, <<"Wed"/utf8>>}}, {thu, {<<"Thursday"/utf8>>, <<"Thu"/utf8>>}}, {fri, {<<"Friday"/utf8>>, <<"Fri"/utf8>>}}, {sat, {<<"Saturday"/utf8>>, <<"Sat"/utf8>>}}, {sun, {<<"Sunday"/utf8>>, <<"Sun"/utf8>>}}], fun(Weekday_item) -> Strings = erlang:element(2, Weekday_item), (erlang:element(1, Strings) =:= Weekday) orelse (erlang:element( 2, Strings ) =:= Weekday) end ), {error, nil}, fun() -> Rest@1 = gleam@string:trim(Rest), _assert_subject = gleam@regex:from_string(<<"\\s+"/utf8>>), {ok, Whitespace_pattern} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"birl/time"/utf8>>, function => <<"from_http"/utf8>>, line => 399}) end, case gleam@regex:split(Whitespace_pattern, Rest@1) of [Day_string, Month_string, Year_string, Time_string, Offset_string] -> Time_string@1 = gleam@string:replace( Time_string, <<":"/utf8>>, <<""/utf8>> ), case {gleam@int:parse(Day_string), begin _pipe = [{jan, {<<"January"/utf8>>, <<"Jan"/utf8>>}}, {feb, {<<"February"/utf8>>, <<"Feb"/utf8>>}}, {mar, {<<"March"/utf8>>, <<"Mar"/utf8>>}}, {apr, {<<"April"/utf8>>, <<"Apr"/utf8>>}}, {may, {<<"May"/utf8>>, <<"May"/utf8>>}}, {jun, {<<"June"/utf8>>, <<"Jun"/utf8>>}}, {jul, {<<"July"/utf8>>, <<"Jul"/utf8>>}}, {aug, {<<"August"/utf8>>, <<"Aug"/utf8>>}}, {sep, {<<"September"/utf8>>, <<"Sep"/utf8>>}}, {oct, {<<"October"/utf8>>, <<"Oct"/utf8>>}}, {nov, {<<"November"/utf8>>, <<"Nov"/utf8>>}}, {dec, {<<"December"/utf8>>, <<"Dec"/utf8>>}}], _pipe@1 = gleam@list:index_map( _pipe, fun(Index, Month) -> Strings@1 = erlang:element(2, Month), {Index, erlang:element(1, Strings@1), erlang:element(2, Strings@1)} end ), gleam@list:find( _pipe@1, fun(Month@1) -> (erlang:element(2, Month@1) =:= Month_string) orelse (erlang:element(3, Month@1) =:= Month_string) end ) end, gleam@int:parse(Year_string), parse_time(Time_string@1)} of {{ok, Day}, {ok, {Month_index, _, _}}, {ok, Year}, {ok, [Hour, Minute, Second]}} -> case from_parts( {Year, Month_index + 1, Day}, {Hour, Minute, Second, 0}, case Offset_string of <<"GMT"/utf8>> -> <<"Z"/utf8>>; _ -> Offset_string end ) of {ok, Value@2} -> Correct_weekday = string_weekday(Value@2), Correct_short_weekday = short_string_weekday( Value@2 ), case gleam@list:contains( [Correct_weekday, Correct_short_weekday], Weekday ) of true -> {ok, Value@2}; false -> {error, nil} end; {error, nil} -> {error, nil} end; _ -> {error, nil} end; [Date_string, Time_string@2, Offset_string@1] -> case gleam@string:split(Date_string, <<"-"/utf8>>) of [Day_string@1, Month_string@1, Year_string@1] -> Time_string@3 = gleam@string:replace( Time_string@2, <<":"/utf8>>, <<""/utf8>> ), case {gleam@int:parse(Day_string@1), begin _pipe@2 = [{jan, {<<"January"/utf8>>, <<"Jan"/utf8>>}}, {feb, {<<"February"/utf8>>, <<"Feb"/utf8>>}}, {mar, {<<"March"/utf8>>, <<"Mar"/utf8>>}}, {apr, {<<"April"/utf8>>, <<"Apr"/utf8>>}}, {may, {<<"May"/utf8>>, <<"May"/utf8>>}}, {jun, {<<"June"/utf8>>, <<"Jun"/utf8>>}}, {jul, {<<"July"/utf8>>, <<"Jul"/utf8>>}}, {aug, {<<"August"/utf8>>, <<"Aug"/utf8>>}}, {sep, {<<"September"/utf8>>, <<"Sep"/utf8>>}}, {oct, {<<"October"/utf8>>, <<"Oct"/utf8>>}}, {nov, {<<"November"/utf8>>, <<"Nov"/utf8>>}}, {dec, {<<"December"/utf8>>, <<"Dec"/utf8>>}}], _pipe@3 = gleam@list:index_map( _pipe@2, fun(Index@1, Month@2) -> Strings@2 = erlang:element( 2, Month@2 ), {Index@1, erlang:element(1, Strings@2), erlang:element(2, Strings@2)} end ), gleam@list:find( _pipe@3, fun(Month@3) -> (erlang:element(2, Month@3) =:= Month_string@1) orelse (erlang:element(3, Month@3) =:= Month_string@1) end ) end, gleam@int:parse(Year_string@1), parse_time(Time_string@3)} of {{ok, Day@1}, {ok, {Month_index@1, _, _}}, {ok, Year@1}, {ok, [Hour@1, Minute@1, Second@1]}} -> case from_parts( {Year@1, Month_index@1 + 1, Day@1}, {Hour@1, Minute@1, Second@1, 0}, case Offset_string@1 of <<"GMT"/utf8>> -> <<"Z"/utf8>>; _ -> Offset_string@1 end ) of {ok, Value@3} -> Correct_weekday@1 = string_weekday( Value@3 ), Correct_short_weekday@1 = short_string_weekday( Value@3 ), case gleam@list:contains( [Correct_weekday@1, Correct_short_weekday@1], Weekday ) of true -> {ok, Value@3}; false -> {error, nil} end; {error, nil} -> {error, nil} end; _ -> {error, nil} end; _ -> {error, nil} end; _ -> {error, nil} end end ). -spec local_timezone() -> binary(). local_timezone() -> birl_ffi:local_timezone(). -spec now() -> date_time(). now() -> Now = birl_ffi:now(), Offset_in_minutes = birl_ffi:local_offset(), Monotonic_now = birl_ffi:monotonic_now(), Timezone = birl_ffi:local_timezone(), case begin _pipe = [{<<"America/Santarem"/utf8>>, -10800}, {<<"America/Ciudad_Juarez"/utf8>>, -25200}, {<<"Asia/Almaty"/utf8>>, 21600}, {<<"America/Manaus"/utf8>>, -14400}, {<<"America/Adak"/utf8>>, -36000}, {<<"EST5EDT"/utf8>>, -18000}, {<<"Europe/Belgrade"/utf8>>, 3600}, {<<"Asia/Famagusta"/utf8>>, 7200}, {<<"Asia/Kabul"/utf8>>, 16200}, {<<"America/Bahia_Banderas"/utf8>>, -21600}, {<<"America/Indiana/Vevay"/utf8>>, -18000}, {<<"Atlantic/Stanley"/utf8>>, -10800}, {<<"Africa/Ndjamena"/utf8>>, 3600}, {<<"Pacific/Marquesas"/utf8>>, -34200}, {<<"Atlantic/Azores"/utf8>>, -3600}, {<<"Asia/Jerusalem"/utf8>>, 7200}, {<<"Africa/Nairobi"/utf8>>, 10800}, {<<"Asia/Tehran"/utf8>>, 12600}, {<<"America/Anchorage"/utf8>>, -32400}, {<<"America/Belem"/utf8>>, -10800}, {<<"America/Paramaribo"/utf8>>, -10800}, {<<"Etc/GMT+3"/utf8>>, -10800}, {<<"Etc/GMT+10"/utf8>>, -36000}, {<<"Asia/Novokuznetsk"/utf8>>, 25200}, {<<"Africa/Monrovia"/utf8>>, 0}, {<<"Asia/Ho_Chi_Minh"/utf8>>, 25200}, {<<"Asia/Makassar"/utf8>>, 28800}, {<<"MST7MDT"/utf8>>, -25200}, {<<"Pacific/Rarotonga"/utf8>>, -36000}, {<<"America/Ojinaga"/utf8>>, -21600}, {<<"Europe/Helsinki"/utf8>>, 7200}, {<<"Europe/Tirane"/utf8>>, 3600}, {<<"America/Noronha"/utf8>>, -7200}, {<<"Etc/GMT-4"/utf8>>, 14400}, {<<"Etc/GMT-14"/utf8>>, 50400}, {<<"Atlantic/Bermuda"/utf8>>, -14400}, {<<"America/Indiana/Winamac"/utf8>>, -18000}, {<<"America/Nuuk"/utf8>>, -7200}, {<<"America/Rankin_Inlet"/utf8>>, -21600}, {<<"Atlantic/South_Georgia"/utf8>>, -7200}, {<<"America/Tijuana"/utf8>>, -28800}, {<<"Asia/Nicosia"/utf8>>, 7200}, {<<"Pacific/Pago_Pago"/utf8>>, -39600}, {<<"America/Barbados"/utf8>>, -14400}, {<<"Asia/Tomsk"/utf8>>, 25200}, {<<"Asia/Baku"/utf8>>, 14400}, {<<"America/Argentina/Buenos_Aires"/utf8>>, -10800}, {<<"Antarctica/Mawson"/utf8>>, 18000}, {<<"Australia/Broken_Hill"/utf8>>, 34200}, {<<"America/Bogota"/utf8>>, -18000}, {<<"Asia/Macau"/utf8>>, 28800}, {<<"Pacific/Tahiti"/utf8>>, -36000}, {<<"America/Thule"/utf8>>, -14400}, {<<"Indian/Maldives"/utf8>>, 18000}, {<<"America/Whitehorse"/utf8>>, -25200}, {<<"America/Indiana/Vincennes"/utf8>>, -18000}, {<<"America/Argentina/Rio_Gallegos"/utf8>>, -10800}, {<<"America/Fort_Nelson"/utf8>>, -25200}, {<<"Asia/Shanghai"/utf8>>, 28800}, {<<"America/Nome"/utf8>>, -32400}, {<<"Asia/Choibalsan"/utf8>>, 28800}, {<<"Pacific/Palau"/utf8>>, 32400}, {<<"America/Halifax"/utf8>>, -14400}, {<<"Etc/UTC"/utf8>>, 0}, {<<"Europe/Bucharest"/utf8>>, 7200}, {<<"Antarctica/Davis"/utf8>>, 25200}, {<<"Etc/GMT+4"/utf8>>, -14400}, {<<"Asia/Jakarta"/utf8>>, 25200}, {<<"Africa/Sao_Tome"/utf8>>, 0}, {<<"Asia/Qyzylorda"/utf8>>, 18000}, {<<"Asia/Hovd"/utf8>>, 25200}, {<<"Africa/Khartoum"/utf8>>, 7200}, {<<"Antarctica/Troll"/utf8>>, 0}, {<<"Asia/Anadyr"/utf8>>, 43200}, {<<"HST"/utf8>>, -36000}, {<<"CST6CDT"/utf8>>, -21600}, {<<"America/Glace_Bay"/utf8>>, -14400}, {<<"Africa/Tripoli"/utf8>>, 7200}, {<<"Europe/Berlin"/utf8>>, 3600}, {<<"Europe/Tallinn"/utf8>>, 7200}, {<<"America/La_Paz"/utf8>>, -14400}, {<<"America/Mazatlan"/utf8>>, -25200}, {<<"Pacific/Nauru"/utf8>>, 43200}, {<<"Asia/Sakhalin"/utf8>>, 39600}, {<<"America/Puerto_Rico"/utf8>>, -14400}, {<<"Pacific/Norfolk"/utf8>>, 39600}, {<<"America/Danmarkshavn"/utf8>>, 0}, {<<"Pacific/Auckland"/utf8>>, 43200}, {<<"America/Argentina/Catamarca"/utf8>>, -10800}, {<<"America/Porto_Velho"/utf8>>, -14400}, {<<"America/Cayenne"/utf8>>, -10800}, {<<"Etc/GMT-5"/utf8>>, 18000}, {<<"Pacific/Guadalcanal"/utf8>>, 39600}, {<<"America/Indiana/Tell_City"/utf8>>, -21600}, {<<"Asia/Kamchatka"/utf8>>, 43200}, {<<"Europe/Vilnius"/utf8>>, 7200}, {<<"Asia/Bishkek"/utf8>>, 21600}, {<<"America/New_York"/utf8>>, -18000}, {<<"America/Belize"/utf8>>, -21600}, {<<"Africa/Algiers"/utf8>>, 3600}, {<<"Asia/Yerevan"/utf8>>, 14400}, {<<"America/Jamaica"/utf8>>, -18000}, {<<"Europe/Madrid"/utf8>>, 3600}, {<<"Asia/Aqtau"/utf8>>, 18000}, {<<"Asia/Vladivostok"/utf8>>, 36000}, {<<"Europe/Kirov"/utf8>>, 10800}, {<<"Asia/Chita"/utf8>>, 32400}, {<<"WET"/utf8>>, 0}, {<<"Australia/Perth"/utf8>>, 28800}, {<<"America/Argentina/San_Juan"/utf8>>, -10800}, {<<"Asia/Yangon"/utf8>>, 23400}, {<<"America/Goose_Bay"/utf8>>, -14400}, {<<"Asia/Gaza"/utf8>>, 7200}, {<<"America/Chicago"/utf8>>, -21600}, {<<"Africa/Cairo"/utf8>>, 7200}, {<<"Asia/Seoul"/utf8>>, 32400}, {<<"America/Scoresbysund"/utf8>>, -3600}, {<<"Europe/Gibraltar"/utf8>>, 3600}, {<<"Europe/Volgograd"/utf8>>, 10800}, {<<"Asia/Urumqi"/utf8>>, 21600}, {<<"Asia/Irkutsk"/utf8>>, 28800}, {<<"America/Resolute"/utf8>>, -21600}, {<<"America/Martinique"/utf8>>, -14400}, {<<"America/Asuncion"/utf8>>, -14400}, {<<"Africa/El_Aaiun"/utf8>>, 3600}, {<<"America/Dawson"/utf8>>, -25200}, {<<"America/Panama"/utf8>>, -18000}, {<<"Asia/Novosibirsk"/utf8>>, 25200}, {<<"Antarctica/Palmer"/utf8>>, -10800}, {<<"Etc/GMT-8"/utf8>>, 28800}, {<<"America/Juneau"/utf8>>, -32400}, {<<"America/Guayaquil"/utf8>>, -18000}, {<<"Asia/Ulaanbaatar"/utf8>>, 28800}, {<<"Asia/Taipei"/utf8>>, 28800}, {<<"Pacific/Chatham"/utf8>>, 45900}, {<<"Etc/GMT+2"/utf8>>, -7200}, {<<"Europe/Budapest"/utf8>>, 3600}, {<<"America/Havana"/utf8>>, -18000}, {<<"Etc/GMT+12"/utf8>>, -43200}, {<<"Africa/Tunis"/utf8>>, 3600}, {<<"Asia/Kolkata"/utf8>>, 19800}, {<<"America/Denver"/utf8>>, -25200}, {<<"America/Menominee"/utf8>>, -21600}, {<<"Asia/Dhaka"/utf8>>, 21600}, {<<"Asia/Hong_Kong"/utf8>>, 28800}, {<<"Asia/Magadan"/utf8>>, 39600}, {<<"Asia/Pontianak"/utf8>>, 25200}, {<<"Asia/Dubai"/utf8>>, 14400}, {<<"America/Indiana/Petersburg"/utf8>>, -18000}, {<<"America/Winnipeg"/utf8>>, -21600}, {<<"America/Vancouver"/utf8>>, -28800}, {<<"America/Detroit"/utf8>>, -18000}, {<<"America/Bahia"/utf8>>, -10800}, {<<"Pacific/Galapagos"/utf8>>, -21600}, {<<"Africa/Windhoek"/utf8>>, 7200}, {<<"Pacific/Kiritimati"/utf8>>, 50400}, {<<"Etc/GMT-1"/utf8>>, 3600}, {<<"Europe/Andorra"/utf8>>, 3600}, {<<"America/Merida"/utf8>>, -21600}, {<<"Africa/Lagos"/utf8>>, 3600}, {<<"America/Mexico_City"/utf8>>, -21600}, {<<"Asia/Yekaterinburg"/utf8>>, 18000}, {<<"America/Argentina/Cordoba"/utf8>>, -10800}, {<<"Asia/Kuching"/utf8>>, 28800}, {<<"Asia/Manila"/utf8>>, 28800}, {<<"Australia/Lindeman"/utf8>>, 36000}, {<<"Asia/Dushanbe"/utf8>>, 18000}, {<<"Pacific/Pitcairn"/utf8>>, -28800}, {<<"Etc/GMT-12"/utf8>>, 43200}, {<<"America/Punta_Arenas"/utf8>>, -10800}, {<<"America/Maceio"/utf8>>, -10800}, {<<"America/Guyana"/utf8>>, -14400}, {<<"Asia/Pyongyang"/utf8>>, 32400}, {<<"Antarctica/Macquarie"/utf8>>, 36000}, {<<"Pacific/Kosrae"/utf8>>, 39600}, {<<"Africa/Juba"/utf8>>, 7200}, {<<"Indian/Mauritius"/utf8>>, 14400}, {<<"Antarctica/Rothera"/utf8>>, -10800}, {<<"Asia/Colombo"/utf8>>, 19800}, {<<"Asia/Barnaul"/utf8>>, 25200}, {<<"Europe/London"/utf8>>, 0}, {<<"Africa/Ceuta"/utf8>>, 3600}, {<<"America/Guatemala"/utf8>>, -21600}, {<<"Europe/Moscow"/utf8>>, 10800}, {<<"America/Indiana/Knox"/utf8>>, -21600}, {<<"America/Toronto"/utf8>>, -18000}, {<<"Australia/Sydney"/utf8>>, 36000}, {<<"Pacific/Kanton"/utf8>>, 46800}, {<<"Asia/Omsk"/utf8>>, 21600}, {<<"Etc/GMT+6"/utf8>>, -21600}, {<<"Europe/Samara"/utf8>>, 14400}, {<<"America/Kentucky/Louisville"/utf8>>, -18000}, {<<"America/Iqaluit"/utf8>>, -18000}, {<<"CET"/utf8>>, 3600}, {<<"Europe/Saratov"/utf8>>, 14400}, {<<"America/Argentina/Ushuaia"/utf8>>, -10800}, {<<"America/Regina"/utf8>>, -21600}, {<<"Etc/GMT-9"/utf8>>, 32400}, {<<"Etc/GMT+11"/utf8>>, -39600}, {<<"America/Boa_Vista"/utf8>>, -14400}, {<<"MET"/utf8>>, 3600}, {<<"Australia/Adelaide"/utf8>>, 34200}, {<<"EET"/utf8>>, 7200}, {<<"Africa/Casablanca"/utf8>>, 3600}, {<<"America/Chihuahua"/utf8>>, -21600}, {<<"America/Indiana/Marengo"/utf8>>, -18000}, {<<"America/Cambridge_Bay"/utf8>>, -25200}, {<<"Etc/GMT-10"/utf8>>, 36000}, {<<"Australia/Eucla"/utf8>>, 31500}, {<<"Asia/Srednekolymsk"/utf8>>, 39600}, {<<"Europe/Rome"/utf8>>, 3600}, {<<"America/Matamoros"/utf8>>, -21600}, {<<"America/Miquelon"/utf8>>, -10800}, {<<"Pacific/Honolulu"/utf8>>, -36000}, {<<"America/Eirunepe"/utf8>>, -18000}, {<<"Europe/Dublin"/utf8>>, 3600}, {<<"America/Santiago"/utf8>>, -14400}, {<<"America/Argentina/San_Luis"/utf8>>, -10800}, {<<"Asia/Beirut"/utf8>>, 7200}, {<<"Pacific/Fiji"/utf8>>, 43200}, {<<"America/Montevideo"/utf8>>, -10800}, {<<"Asia/Jayapura"/utf8>>, 32400}, {<<"Asia/Qostanay"/utf8>>, 21600}, {<<"Europe/Warsaw"/utf8>>, 3600}, {<<"Asia/Khandyga"/utf8>>, 32400}, {<<"America/Costa_Rica"/utf8>>, -21600}, {<<"America/Sao_Paulo"/utf8>>, -10800}, {<<"America/Argentina/Mendoza"/utf8>>, -10800}, {<<"America/Sitka"/utf8>>, -32400}, {<<"America/Kentucky/Monticello"/utf8>>, -18000}, {<<"America/Argentina/Tucuman"/utf8>>, -10800}, {<<"America/Fortaleza"/utf8>>, -10800}, {<<"America/Araguaina"/utf8>>, -10800}, {<<"America/Monterrey"/utf8>>, -21600}, {<<"Atlantic/Canary"/utf8>>, 0}, {<<"Asia/Atyrau"/utf8>>, 18000}, {<<"Australia/Lord_Howe"/utf8>>, 37800}, {<<"Etc/GMT-3"/utf8>>, 10800}, {<<"Pacific/Apia"/utf8>>, 46800}, {<<"Australia/Hobart"/utf8>>, 36000}, {<<"Europe/Prague"/utf8>>, 3600}, {<<"Asia/Aqtobe"/utf8>>, 18000}, {<<"Africa/Maputo"/utf8>>, 7200}, {<<"Asia/Oral"/utf8>>, 18000}, {<<"Europe/Athens"/utf8>>, 7200}, {<<"Etc/GMT+5"/utf8>>, -18000}, {<<"Europe/Simferopol"/utf8>>, 10800}, {<<"Europe/Brussels"/utf8>>, 3600}, {<<"America/Port-au-Prince"/utf8>>, -18000}, {<<"Etc/GMT-11"/utf8>>, 39600}, {<<"Etc/GMT+9"/utf8>>, -32400}, {<<"America/Argentina/Salta"/utf8>>, -10800}, {<<"Pacific/Niue"/utf8>>, -39600}, {<<"America/Los_Angeles"/utf8>>, -28800}, {<<"Australia/Brisbane"/utf8>>, 36000}, {<<"America/Boise"/utf8>>, -25200}, {<<"America/Edmonton"/utf8>>, -25200}, {<<"Pacific/Port_Moresby"/utf8>>, 36000}, {<<"Pacific/Bougainville"/utf8>>, 39600}, {<<"Asia/Tokyo"/utf8>>, 32400}, {<<"America/Yakutat"/utf8>>, -32400}, {<<"Pacific/Tongatapu"/utf8>>, 46800}, {<<"America/Inuvik"/utf8>>, -25200}, {<<"Indian/Chagos"/utf8>>, 21600}, {<<"America/Caracas"/utf8>>, -14400}, {<<"PST8PDT"/utf8>>, -28800}, {<<"Europe/Lisbon"/utf8>>, 0}, {<<"Asia/Damascus"/utf8>>, 10800}, {<<"Pacific/Efate"/utf8>>, 39600}, {<<"Asia/Karachi"/utf8>>, 18000}, {<<"America/Argentina/La_Rioja"/utf8>>, -10800}, {<<"Africa/Johannesburg"/utf8>>, 7200}, {<<"Australia/Melbourne"/utf8>>, 36000}, {<<"Etc/GMT"/utf8>>, 0}, {<<"Africa/Abidjan"/utf8>>, 0}, {<<"Asia/Dili"/utf8>>, 32400}, {<<"America/Lima"/utf8>>, -18000}, {<<"Europe/Istanbul"/utf8>>, 10800}, {<<"Asia/Ashgabat"/utf8>>, 18000}, {<<"America/Rio_Branco"/utf8>>, -18000}, {<<"America/El_Salvador"/utf8>>, -21600}, {<<"Pacific/Guam"/utf8>>, 36000}, {<<"America/Hermosillo"/utf8>>, -25200}, {<<"America/Metlakatla"/utf8>>, -32400}, {<<"Etc/GMT-7"/utf8>>, 25200}, {<<"Etc/GMT+7"/utf8>>, -25200}, {<<"Europe/Vienna"/utf8>>, 3600}, {<<"Europe/Kaliningrad"/utf8>>, 7200}, {<<"America/St_Johns"/utf8>>, -12600}, {<<"America/North_Dakota/New_Salem"/utf8>>, -21600}, {<<"Asia/Qatar"/utf8>>, 10800}, {<<"America/Recife"/utf8>>, -10800}, {<<"Asia/Thimphu"/utf8>>, 21600}, {<<"Pacific/Noumea"/utf8>>, 39600}, {<<"Europe/Sofia"/utf8>>, 7200}, {<<"Atlantic/Cape_Verde"/utf8>>, -3600}, {<<"Europe/Minsk"/utf8>>, 10800}, {<<"America/Swift_Current"/utf8>>, -21600}, {<<"Europe/Ulyanovsk"/utf8>>, 14400}, {<<"Europe/Kyiv"/utf8>>, 7200}, {<<"Etc/GMT+8"/utf8>>, -28800}, {<<"America/Phoenix"/utf8>>, -25200}, {<<"Pacific/Easter"/utf8>>, -21600}, {<<"America/Argentina/Jujuy"/utf8>>, -10800}, {<<"Asia/Tashkent"/utf8>>, 18000}, {<<"Etc/GMT-6"/utf8>>, 21600}, {<<"Asia/Ust-Nera"/utf8>>, 36000}, {<<"America/Cancun"/utf8>>, -18000}, {<<"America/Cuiaba"/utf8>>, -14400}, {<<"Asia/Riyadh"/utf8>>, 10800}, {<<"Etc/GMT-2"/utf8>>, 7200}, {<<"America/Tegucigalpa"/utf8>>, -21600}, {<<"Asia/Baghdad"/utf8>>, 10800}, {<<"America/Campo_Grande"/utf8>>, -14400}, {<<"EST"/utf8>>, -18000}, {<<"America/Santo_Domingo"/utf8>>, -14400}, {<<"Asia/Kathmandu"/utf8>>, 20700}, {<<"Etc/GMT+1"/utf8>>, -3600}, {<<"Asia/Bangkok"/utf8>>, 25200}, {<<"Asia/Yakutsk"/utf8>>, 32400}, {<<"Atlantic/Madeira"/utf8>>, 0}, {<<"Europe/Paris"/utf8>>, 3600}, {<<"America/Grand_Turk"/utf8>>, -18000}, {<<"Asia/Krasnoyarsk"/utf8>>, 25200}, {<<"America/Managua"/utf8>>, -21600}, {<<"MST"/utf8>>, -25200}, {<<"Etc/GMT-13"/utf8>>, 46800}, {<<"America/North_Dakota/Center"/utf8>>, -21600}, {<<"Europe/Astrakhan"/utf8>>, 14400}, {<<"Pacific/Gambier"/utf8>>, -32400}, {<<"Pacific/Fakaofo"/utf8>>, 46800}, {<<"Atlantic/Faroe"/utf8>>, 0}, {<<"Asia/Samarkand"/utf8>>, 18000}, {<<"Australia/Darwin"/utf8>>, 34200}, {<<"America/Indiana/Indianapolis"/utf8>>, -18000}, {<<"Pacific/Tarawa"/utf8>>, 43200}, {<<"Europe/Malta"/utf8>>, 3600}, {<<"America/Moncton"/utf8>>, -14400}, {<<"Pacific/Kwajalein"/utf8>>, 43200}, {<<"America/Dawson_Creek"/utf8>>, -25200}, {<<"Europe/Chisinau"/utf8>>, 7200}, {<<"Asia/Hebron"/utf8>>, 7200}, {<<"Africa/Bissau"/utf8>>, 0}, {<<"Asia/Tbilisi"/utf8>>, 14400}, {<<"Asia/Amman"/utf8>>, 10800}, {<<"Asia/Singapore"/utf8>>, 28800}, {<<"Antarctica/Casey"/utf8>>, 39600}, {<<"Europe/Riga"/utf8>>, 7200}, {<<"America/North_Dakota/Beulah"/utf8>>, -21600}, {<<"Europe/Zurich"/utf8>>, 3600}], gleam@list:key_find(_pipe, Timezone) end of {ok, _} -> {date_time, Now, Offset_in_minutes * 60000000, {some, Timezone}, {some, Monotonic_now}}; {error, nil} -> {date_time, Now, Offset_in_minutes * 60000000, none, {some, Monotonic_now}} end. -spec from_erlang_local_datetime( {{integer(), integer(), integer()}, {integer(), integer(), integer()}} ) -> date_time(). from_erlang_local_datetime(Erlang_datetime) -> {Date, Time} = Erlang_datetime, Offset_in_minutes = birl_ffi:local_offset(), {date_time, Wall_time, _, none, none} = begin _pipe = {date_time, 0, 0, none, none}, _pipe@1 = set_date( _pipe, {date, erlang:element(1, Date), erlang:element(2, Date), erlang:element(3, Date)} ), set_time( _pipe@1, {time, erlang:element(1, Time), erlang:element(2, Time), erlang:element(3, Time), 0} ) end, Timezone = birl_ffi:local_timezone(), case begin _pipe@2 = [{<<"America/Santarem"/utf8>>, -10800}, {<<"America/Ciudad_Juarez"/utf8>>, -25200}, {<<"Asia/Almaty"/utf8>>, 21600}, {<<"America/Manaus"/utf8>>, -14400}, {<<"America/Adak"/utf8>>, -36000}, {<<"EST5EDT"/utf8>>, -18000}, {<<"Europe/Belgrade"/utf8>>, 3600}, {<<"Asia/Famagusta"/utf8>>, 7200}, {<<"Asia/Kabul"/utf8>>, 16200}, {<<"America/Bahia_Banderas"/utf8>>, -21600}, {<<"America/Indiana/Vevay"/utf8>>, -18000}, {<<"Atlantic/Stanley"/utf8>>, -10800}, {<<"Africa/Ndjamena"/utf8>>, 3600}, {<<"Pacific/Marquesas"/utf8>>, -34200}, {<<"Atlantic/Azores"/utf8>>, -3600}, {<<"Asia/Jerusalem"/utf8>>, 7200}, {<<"Africa/Nairobi"/utf8>>, 10800}, {<<"Asia/Tehran"/utf8>>, 12600}, {<<"America/Anchorage"/utf8>>, -32400}, {<<"America/Belem"/utf8>>, -10800}, {<<"America/Paramaribo"/utf8>>, -10800}, {<<"Etc/GMT+3"/utf8>>, -10800}, {<<"Etc/GMT+10"/utf8>>, -36000}, {<<"Asia/Novokuznetsk"/utf8>>, 25200}, {<<"Africa/Monrovia"/utf8>>, 0}, {<<"Asia/Ho_Chi_Minh"/utf8>>, 25200}, {<<"Asia/Makassar"/utf8>>, 28800}, {<<"MST7MDT"/utf8>>, -25200}, {<<"Pacific/Rarotonga"/utf8>>, -36000}, {<<"America/Ojinaga"/utf8>>, -21600}, {<<"Europe/Helsinki"/utf8>>, 7200}, {<<"Europe/Tirane"/utf8>>, 3600}, {<<"America/Noronha"/utf8>>, -7200}, {<<"Etc/GMT-4"/utf8>>, 14400}, {<<"Etc/GMT-14"/utf8>>, 50400}, {<<"Atlantic/Bermuda"/utf8>>, -14400}, {<<"America/Indiana/Winamac"/utf8>>, -18000}, {<<"America/Nuuk"/utf8>>, -7200}, {<<"America/Rankin_Inlet"/utf8>>, -21600}, {<<"Atlantic/South_Georgia"/utf8>>, -7200}, {<<"America/Tijuana"/utf8>>, -28800}, {<<"Asia/Nicosia"/utf8>>, 7200}, {<<"Pacific/Pago_Pago"/utf8>>, -39600}, {<<"America/Barbados"/utf8>>, -14400}, {<<"Asia/Tomsk"/utf8>>, 25200}, {<<"Asia/Baku"/utf8>>, 14400}, {<<"America/Argentina/Buenos_Aires"/utf8>>, -10800}, {<<"Antarctica/Mawson"/utf8>>, 18000}, {<<"Australia/Broken_Hill"/utf8>>, 34200}, {<<"America/Bogota"/utf8>>, -18000}, {<<"Asia/Macau"/utf8>>, 28800}, {<<"Pacific/Tahiti"/utf8>>, -36000}, {<<"America/Thule"/utf8>>, -14400}, {<<"Indian/Maldives"/utf8>>, 18000}, {<<"America/Whitehorse"/utf8>>, -25200}, {<<"America/Indiana/Vincennes"/utf8>>, -18000}, {<<"America/Argentina/Rio_Gallegos"/utf8>>, -10800}, {<<"America/Fort_Nelson"/utf8>>, -25200}, {<<"Asia/Shanghai"/utf8>>, 28800}, {<<"America/Nome"/utf8>>, -32400}, {<<"Asia/Choibalsan"/utf8>>, 28800}, {<<"Pacific/Palau"/utf8>>, 32400}, {<<"America/Halifax"/utf8>>, -14400}, {<<"Etc/UTC"/utf8>>, 0}, {<<"Europe/Bucharest"/utf8>>, 7200}, {<<"Antarctica/Davis"/utf8>>, 25200}, {<<"Etc/GMT+4"/utf8>>, -14400}, {<<"Asia/Jakarta"/utf8>>, 25200}, {<<"Africa/Sao_Tome"/utf8>>, 0}, {<<"Asia/Qyzylorda"/utf8>>, 18000}, {<<"Asia/Hovd"/utf8>>, 25200}, {<<"Africa/Khartoum"/utf8>>, 7200}, {<<"Antarctica/Troll"/utf8>>, 0}, {<<"Asia/Anadyr"/utf8>>, 43200}, {<<"HST"/utf8>>, -36000}, {<<"CST6CDT"/utf8>>, -21600}, {<<"America/Glace_Bay"/utf8>>, -14400}, {<<"Africa/Tripoli"/utf8>>, 7200}, {<<"Europe/Berlin"/utf8>>, 3600}, {<<"Europe/Tallinn"/utf8>>, 7200}, {<<"America/La_Paz"/utf8>>, -14400}, {<<"America/Mazatlan"/utf8>>, -25200}, {<<"Pacific/Nauru"/utf8>>, 43200}, {<<"Asia/Sakhalin"/utf8>>, 39600}, {<<"America/Puerto_Rico"/utf8>>, -14400}, {<<"Pacific/Norfolk"/utf8>>, 39600}, {<<"America/Danmarkshavn"/utf8>>, 0}, {<<"Pacific/Auckland"/utf8>>, 43200}, {<<"America/Argentina/Catamarca"/utf8>>, -10800}, {<<"America/Porto_Velho"/utf8>>, -14400}, {<<"America/Cayenne"/utf8>>, -10800}, {<<"Etc/GMT-5"/utf8>>, 18000}, {<<"Pacific/Guadalcanal"/utf8>>, 39600}, {<<"America/Indiana/Tell_City"/utf8>>, -21600}, {<<"Asia/Kamchatka"/utf8>>, 43200}, {<<"Europe/Vilnius"/utf8>>, 7200}, {<<"Asia/Bishkek"/utf8>>, 21600}, {<<"America/New_York"/utf8>>, -18000}, {<<"America/Belize"/utf8>>, -21600}, {<<"Africa/Algiers"/utf8>>, 3600}, {<<"Asia/Yerevan"/utf8>>, 14400}, {<<"America/Jamaica"/utf8>>, -18000}, {<<"Europe/Madrid"/utf8>>, 3600}, {<<"Asia/Aqtau"/utf8>>, 18000}, {<<"Asia/Vladivostok"/utf8>>, 36000}, {<<"Europe/Kirov"/utf8>>, 10800}, {<<"Asia/Chita"/utf8>>, 32400}, {<<"WET"/utf8>>, 0}, {<<"Australia/Perth"/utf8>>, 28800}, {<<"America/Argentina/San_Juan"/utf8>>, -10800}, {<<"Asia/Yangon"/utf8>>, 23400}, {<<"America/Goose_Bay"/utf8>>, -14400}, {<<"Asia/Gaza"/utf8>>, 7200}, {<<"America/Chicago"/utf8>>, -21600}, {<<"Africa/Cairo"/utf8>>, 7200}, {<<"Asia/Seoul"/utf8>>, 32400}, {<<"America/Scoresbysund"/utf8>>, -3600}, {<<"Europe/Gibraltar"/utf8>>, 3600}, {<<"Europe/Volgograd"/utf8>>, 10800}, {<<"Asia/Urumqi"/utf8>>, 21600}, {<<"Asia/Irkutsk"/utf8>>, 28800}, {<<"America/Resolute"/utf8>>, -21600}, {<<"America/Martinique"/utf8>>, -14400}, {<<"America/Asuncion"/utf8>>, -14400}, {<<"Africa/El_Aaiun"/utf8>>, 3600}, {<<"America/Dawson"/utf8>>, -25200}, {<<"America/Panama"/utf8>>, -18000}, {<<"Asia/Novosibirsk"/utf8>>, 25200}, {<<"Antarctica/Palmer"/utf8>>, -10800}, {<<"Etc/GMT-8"/utf8>>, 28800}, {<<"America/Juneau"/utf8>>, -32400}, {<<"America/Guayaquil"/utf8>>, -18000}, {<<"Asia/Ulaanbaatar"/utf8>>, 28800}, {<<"Asia/Taipei"/utf8>>, 28800}, {<<"Pacific/Chatham"/utf8>>, 45900}, {<<"Etc/GMT+2"/utf8>>, -7200}, {<<"Europe/Budapest"/utf8>>, 3600}, {<<"America/Havana"/utf8>>, -18000}, {<<"Etc/GMT+12"/utf8>>, -43200}, {<<"Africa/Tunis"/utf8>>, 3600}, {<<"Asia/Kolkata"/utf8>>, 19800}, {<<"America/Denver"/utf8>>, -25200}, {<<"America/Menominee"/utf8>>, -21600}, {<<"Asia/Dhaka"/utf8>>, 21600}, {<<"Asia/Hong_Kong"/utf8>>, 28800}, {<<"Asia/Magadan"/utf8>>, 39600}, {<<"Asia/Pontianak"/utf8>>, 25200}, {<<"Asia/Dubai"/utf8>>, 14400}, {<<"America/Indiana/Petersburg"/utf8>>, -18000}, {<<"America/Winnipeg"/utf8>>, -21600}, {<<"America/Vancouver"/utf8>>, -28800}, {<<"America/Detroit"/utf8>>, -18000}, {<<"America/Bahia"/utf8>>, -10800}, {<<"Pacific/Galapagos"/utf8>>, -21600}, {<<"Africa/Windhoek"/utf8>>, 7200}, {<<"Pacific/Kiritimati"/utf8>>, 50400}, {<<"Etc/GMT-1"/utf8>>, 3600}, {<<"Europe/Andorra"/utf8>>, 3600}, {<<"America/Merida"/utf8>>, -21600}, {<<"Africa/Lagos"/utf8>>, 3600}, {<<"America/Mexico_City"/utf8>>, -21600}, {<<"Asia/Yekaterinburg"/utf8>>, 18000}, {<<"America/Argentina/Cordoba"/utf8>>, -10800}, {<<"Asia/Kuching"/utf8>>, 28800}, {<<"Asia/Manila"/utf8>>, 28800}, {<<"Australia/Lindeman"/utf8>>, 36000}, {<<"Asia/Dushanbe"/utf8>>, 18000}, {<<"Pacific/Pitcairn"/utf8>>, -28800}, {<<"Etc/GMT-12"/utf8>>, 43200}, {<<"America/Punta_Arenas"/utf8>>, -10800}, {<<"America/Maceio"/utf8>>, -10800}, {<<"America/Guyana"/utf8>>, -14400}, {<<"Asia/Pyongyang"/utf8>>, 32400}, {<<"Antarctica/Macquarie"/utf8>>, 36000}, {<<"Pacific/Kosrae"/utf8>>, 39600}, {<<"Africa/Juba"/utf8>>, 7200}, {<<"Indian/Mauritius"/utf8>>, 14400}, {<<"Antarctica/Rothera"/utf8>>, -10800}, {<<"Asia/Colombo"/utf8>>, 19800}, {<<"Asia/Barnaul"/utf8>>, 25200}, {<<"Europe/London"/utf8>>, 0}, {<<"Africa/Ceuta"/utf8>>, 3600}, {<<"America/Guatemala"/utf8>>, -21600}, {<<"Europe/Moscow"/utf8>>, 10800}, {<<"America/Indiana/Knox"/utf8>>, -21600}, {<<"America/Toronto"/utf8>>, -18000}, {<<"Australia/Sydney"/utf8>>, 36000}, {<<"Pacific/Kanton"/utf8>>, 46800}, {<<"Asia/Omsk"/utf8>>, 21600}, {<<"Etc/GMT+6"/utf8>>, -21600}, {<<"Europe/Samara"/utf8>>, 14400}, {<<"America/Kentucky/Louisville"/utf8>>, -18000}, {<<"America/Iqaluit"/utf8>>, -18000}, {<<"CET"/utf8>>, 3600}, {<<"Europe/Saratov"/utf8>>, 14400}, {<<"America/Argentina/Ushuaia"/utf8>>, -10800}, {<<"America/Regina"/utf8>>, -21600}, {<<"Etc/GMT-9"/utf8>>, 32400}, {<<"Etc/GMT+11"/utf8>>, -39600}, {<<"America/Boa_Vista"/utf8>>, -14400}, {<<"MET"/utf8>>, 3600}, {<<"Australia/Adelaide"/utf8>>, 34200}, {<<"EET"/utf8>>, 7200}, {<<"Africa/Casablanca"/utf8>>, 3600}, {<<"America/Chihuahua"/utf8>>, -21600}, {<<"America/Indiana/Marengo"/utf8>>, -18000}, {<<"America/Cambridge_Bay"/utf8>>, -25200}, {<<"Etc/GMT-10"/utf8>>, 36000}, {<<"Australia/Eucla"/utf8>>, 31500}, {<<"Asia/Srednekolymsk"/utf8>>, 39600}, {<<"Europe/Rome"/utf8>>, 3600}, {<<"America/Matamoros"/utf8>>, -21600}, {<<"America/Miquelon"/utf8>>, -10800}, {<<"Pacific/Honolulu"/utf8>>, -36000}, {<<"America/Eirunepe"/utf8>>, -18000}, {<<"Europe/Dublin"/utf8>>, 3600}, {<<"America/Santiago"/utf8>>, -14400}, {<<"America/Argentina/San_Luis"/utf8>>, -10800}, {<<"Asia/Beirut"/utf8>>, 7200}, {<<"Pacific/Fiji"/utf8>>, 43200}, {<<"America/Montevideo"/utf8>>, -10800}, {<<"Asia/Jayapura"/utf8>>, 32400}, {<<"Asia/Qostanay"/utf8>>, 21600}, {<<"Europe/Warsaw"/utf8>>, 3600}, {<<"Asia/Khandyga"/utf8>>, 32400}, {<<"America/Costa_Rica"/utf8>>, -21600}, {<<"America/Sao_Paulo"/utf8>>, -10800}, {<<"America/Argentina/Mendoza"/utf8>>, -10800}, {<<"America/Sitka"/utf8>>, -32400}, {<<"America/Kentucky/Monticello"/utf8>>, -18000}, {<<"America/Argentina/Tucuman"/utf8>>, -10800}, {<<"America/Fortaleza"/utf8>>, -10800}, {<<"America/Araguaina"/utf8>>, -10800}, {<<"America/Monterrey"/utf8>>, -21600}, {<<"Atlantic/Canary"/utf8>>, 0}, {<<"Asia/Atyrau"/utf8>>, 18000}, {<<"Australia/Lord_Howe"/utf8>>, 37800}, {<<"Etc/GMT-3"/utf8>>, 10800}, {<<"Pacific/Apia"/utf8>>, 46800}, {<<"Australia/Hobart"/utf8>>, 36000}, {<<"Europe/Prague"/utf8>>, 3600}, {<<"Asia/Aqtobe"/utf8>>, 18000}, {<<"Africa/Maputo"/utf8>>, 7200}, {<<"Asia/Oral"/utf8>>, 18000}, {<<"Europe/Athens"/utf8>>, 7200}, {<<"Etc/GMT+5"/utf8>>, -18000}, {<<"Europe/Simferopol"/utf8>>, 10800}, {<<"Europe/Brussels"/utf8>>, 3600}, {<<"America/Port-au-Prince"/utf8>>, -18000}, {<<"Etc/GMT-11"/utf8>>, 39600}, {<<"Etc/GMT+9"/utf8>>, -32400}, {<<"America/Argentina/Salta"/utf8>>, -10800}, {<<"Pacific/Niue"/utf8>>, -39600}, {<<"America/Los_Angeles"/utf8>>, -28800}, {<<"Australia/Brisbane"/utf8>>, 36000}, {<<"America/Boise"/utf8>>, -25200}, {<<"America/Edmonton"/utf8>>, -25200}, {<<"Pacific/Port_Moresby"/utf8>>, 36000}, {<<"Pacific/Bougainville"/utf8>>, 39600}, {<<"Asia/Tokyo"/utf8>>, 32400}, {<<"America/Yakutat"/utf8>>, -32400}, {<<"Pacific/Tongatapu"/utf8>>, 46800}, {<<"America/Inuvik"/utf8>>, -25200}, {<<"Indian/Chagos"/utf8>>, 21600}, {<<"America/Caracas"/utf8>>, -14400}, {<<"PST8PDT"/utf8>>, -28800}, {<<"Europe/Lisbon"/utf8>>, 0}, {<<"Asia/Damascus"/utf8>>, 10800}, {<<"Pacific/Efate"/utf8>>, 39600}, {<<"Asia/Karachi"/utf8>>, 18000}, {<<"America/Argentina/La_Rioja"/utf8>>, -10800}, {<<"Africa/Johannesburg"/utf8>>, 7200}, {<<"Australia/Melbourne"/utf8>>, 36000}, {<<"Etc/GMT"/utf8>>, 0}, {<<"Africa/Abidjan"/utf8>>, 0}, {<<"Asia/Dili"/utf8>>, 32400}, {<<"America/Lima"/utf8>>, -18000}, {<<"Europe/Istanbul"/utf8>>, 10800}, {<<"Asia/Ashgabat"/utf8>>, 18000}, {<<"America/Rio_Branco"/utf8>>, -18000}, {<<"America/El_Salvador"/utf8>>, -21600}, {<<"Pacific/Guam"/utf8>>, 36000}, {<<"America/Hermosillo"/utf8>>, -25200}, {<<"America/Metlakatla"/utf8>>, -32400}, {<<"Etc/GMT-7"/utf8>>, 25200}, {<<"Etc/GMT+7"/utf8>>, -25200}, {<<"Europe/Vienna"/utf8>>, 3600}, {<<"Europe/Kaliningrad"/utf8>>, 7200}, {<<"America/St_Johns"/utf8>>, -12600}, {<<"America/North_Dakota/New_Salem"/utf8>>, -21600}, {<<"Asia/Qatar"/utf8>>, 10800}, {<<"America/Recife"/utf8>>, -10800}, {<<"Asia/Thimphu"/utf8>>, 21600}, {<<"Pacific/Noumea"/utf8>>, 39600}, {<<"Europe/Sofia"/utf8>>, 7200}, {<<"Atlantic/Cape_Verde"/utf8>>, -3600}, {<<"Europe/Minsk"/utf8>>, 10800}, {<<"America/Swift_Current"/utf8>>, -21600}, {<<"Europe/Ulyanovsk"/utf8>>, 14400}, {<<"Europe/Kyiv"/utf8>>, 7200}, {<<"Etc/GMT+8"/utf8>>, -28800}, {<<"America/Phoenix"/utf8>>, -25200}, {<<"Pacific/Easter"/utf8>>, -21600}, {<<"America/Argentina/Jujuy"/utf8>>, -10800}, {<<"Asia/Tashkent"/utf8>>, 18000}, {<<"Etc/GMT-6"/utf8>>, 21600}, {<<"Asia/Ust-Nera"/utf8>>, 36000}, {<<"America/Cancun"/utf8>>, -18000}, {<<"America/Cuiaba"/utf8>>, -14400}, {<<"Asia/Riyadh"/utf8>>, 10800}, {<<"Etc/GMT-2"/utf8>>, 7200}, {<<"America/Tegucigalpa"/utf8>>, -21600}, {<<"Asia/Baghdad"/utf8>>, 10800}, {<<"America/Campo_Grande"/utf8>>, -14400}, {<<"EST"/utf8>>, -18000}, {<<"America/Santo_Domingo"/utf8>>, -14400}, {<<"Asia/Kathmandu"/utf8>>, 20700}, {<<"Etc/GMT+1"/utf8>>, -3600}, {<<"Asia/Bangkok"/utf8>>, 25200}, {<<"Asia/Yakutsk"/utf8>>, 32400}, {<<"Atlantic/Madeira"/utf8>>, 0}, {<<"Europe/Paris"/utf8>>, 3600}, {<<"America/Grand_Turk"/utf8>>, -18000}, {<<"Asia/Krasnoyarsk"/utf8>>, 25200}, {<<"America/Managua"/utf8>>, -21600}, {<<"MST"/utf8>>, -25200}, {<<"Etc/GMT-13"/utf8>>, 46800}, {<<"America/North_Dakota/Center"/utf8>>, -21600}, {<<"Europe/Astrakhan"/utf8>>, 14400}, {<<"Pacific/Gambier"/utf8>>, -32400}, {<<"Pacific/Fakaofo"/utf8>>, 46800}, {<<"Atlantic/Faroe"/utf8>>, 0}, {<<"Asia/Samarkand"/utf8>>, 18000}, {<<"Australia/Darwin"/utf8>>, 34200}, {<<"America/Indiana/Indianapolis"/utf8>>, -18000}, {<<"Pacific/Tarawa"/utf8>>, 43200}, {<<"Europe/Malta"/utf8>>, 3600}, {<<"America/Moncton"/utf8>>, -14400}, {<<"Pacific/Kwajalein"/utf8>>, 43200}, {<<"America/Dawson_Creek"/utf8>>, -25200}, {<<"Europe/Chisinau"/utf8>>, 7200}, {<<"Asia/Hebron"/utf8>>, 7200}, {<<"Africa/Bissau"/utf8>>, 0}, {<<"Asia/Tbilisi"/utf8>>, 14400}, {<<"Asia/Amman"/utf8>>, 10800}, {<<"Asia/Singapore"/utf8>>, 28800}, {<<"Antarctica/Casey"/utf8>>, 39600}, {<<"Europe/Riga"/utf8>>, 7200}, {<<"America/North_Dakota/Beulah"/utf8>>, -21600}, {<<"Europe/Zurich"/utf8>>, 3600}], gleam@list:key_find(_pipe@2, Timezone) end of {ok, _} -> {date_time, Wall_time, Offset_in_minutes * 60000000, {some, Timezone}, none}; {error, nil} -> {date_time, Wall_time, Offset_in_minutes * 60000000, none, none} end.