Current section
Files
Jump to
Current section
Files
src/tempo@datetime.erl
-module(tempo@datetime).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([new/3, now_utc/0, from_string/1, literal/1, to_string/1, parse/2, parse_any/1, from_unix_utc/1, from_unix_milli_utc/1, from_unix_micro_utc/1, from_dynamic_string/1, from_dynamic_unix_utc/1, from_dynamic_unix_milli_utc/1, from_dynamic_unix_micro_utc/1, get_date/1, get_time/1, get_offset/1, format/2, drop_offset/1, drop_time/1, apply_offset/1, to_unix_utc/1, to_unix_milli_utc/1, to_unix_micro_utc/1, to_utc/1, to_offset/2, to_local/1, now_local/0, to_local_time/1, to_local_date/1, to_timezone/2, get_timezone_name/1, compare/2, is_earlier/2, is_earlier_or_equal/2, is_equal/2, is_later/2, is_later_or_equal/2, difference/2, as_period/2, add/2, subtract/2, time_left_in_day/1]).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 75).
-spec new(tempo:date(), tempo:time(), tempo:offset()) -> tempo:date_time().
new(Date, Time, Offset) ->
tempo:datetime(tempo@naive_datetime:new(Date, Time), Offset).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 140).
-spec now_utc() -> tempo:date_time().
now_utc() ->
{Now_monotonic, Now_unique} = tempo:now_monounique(),
Now_ts_nano = tempo_ffi:now(),
new(
tempo@date:from_unix_utc(Now_ts_nano div 1000000000),
begin
_pipe = tempo@time:from_unix_nano_utc(Now_ts_nano),
tempo:time_set_mono(
_pipe,
{some, Now_monotonic},
{some, Now_unique}
)
end,
{offset, 0}
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 205).
-spec split_time_and_offset(binary()) -> {ok, {binary(), binary()}} |
{error, tempo:date_time_parse_error()}.
split_time_and_offset(Time_with_offset) ->
case gleam@string:slice(Time_with_offset, -1, 1) of
<<"Z"/utf8>> ->
_pipe = {gleam@string:drop_right(Time_with_offset, 1), <<"Z"/utf8>>},
{ok, _pipe};
<<"z"/utf8>> ->
_pipe@1 = {gleam@string:drop_right(Time_with_offset, 1),
<<"Z"/utf8>>},
{ok, _pipe@1};
_ ->
case gleam@string:split(Time_with_offset, <<"-"/utf8>>) of
[Time, Offset] ->
_pipe@2 = {Time, <<"-"/utf8, Offset/binary>>},
{ok, _pipe@2};
_ ->
case gleam@string:split(Time_with_offset, <<"+"/utf8>>) of
[Time@1, Offset@1] ->
_pipe@3 = {Time@1, <<"+"/utf8, Offset@1/binary>>},
{ok, _pipe@3};
_ ->
{error, date_time_invalid_format}
end
end
end.
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 165).
-spec from_string(binary()) -> {ok, tempo:date_time()} |
{error, tempo:date_time_parse_error()}.
from_string(Datetime) ->
Split_dt = case gleam_stdlib:contains_string(Datetime, <<"T"/utf8>>) of
true ->
gleam@string:split(Datetime, <<"T"/utf8>>);
false ->
gleam@string:split(Datetime, <<" "/utf8>>)
end,
case Split_dt of
[Date, Time] ->
gleam@result:'try'(
begin
_pipe = tempo@date:from_string(Date),
gleam@result:map_error(
_pipe,
fun(E) -> {date_time_date_parse_error, E} end
)
end,
fun(Date@1) ->
gleam@result:'try'(
split_time_and_offset(Time),
fun(_use0) ->
{Time@1, Offset} = _use0,
gleam@result:'try'(
begin
_pipe@1 = tempo@time:from_string(Time@1),
gleam@result:map_error(
_pipe@1,
fun(E@1) ->
{date_time_time_parse_error, E@1}
end
)
end,
fun(Time@2) ->
gleam@result:map(
begin
_pipe@2 = tempo@offset:from_string(
Offset
),
gleam@result:map_error(
_pipe@2,
fun(E@2) ->
{date_time_offset_parse_error,
E@2}
end
)
end,
fun(Offset@1) ->
new(Date@1, Time@2, Offset@1)
end
)
end
)
end
)
end
);
[Date@2] ->
_pipe@3 = tempo@date:from_string(Date@2),
_pipe@4 = gleam@result:map(
_pipe@3,
fun(_capture) ->
new(
_capture,
tempo:time(0, 0, 0, 0, none, none),
{offset, 0}
)
end
),
gleam@result:map_error(
_pipe@4,
fun(E@3) -> {date_time_date_parse_error, E@3} end
);
_ ->
{error, date_time_invalid_format}
end.
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 97).
-spec literal(binary()) -> tempo:date_time().
literal(Datetime) ->
case from_string(Datetime) of
{ok, Datetime@1} ->
Datetime@1;
{error, date_time_invalid_format} ->
erlang:error(#{gleam_error => panic,
message => <<"Invalid datetime literal format"/utf8>>,
module => <<"tempo/datetime"/utf8>>,
function => <<"literal"/utf8>>,
line => 101});
{error, {date_time_date_parse_error, _}} ->
erlang:error(#{gleam_error => panic,
message => <<"Invalid date in datetime literal value"/utf8>>,
module => <<"tempo/datetime"/utf8>>,
function => <<"literal"/utf8>>,
line => 103});
{error, {date_time_time_parse_error, _}} ->
erlang:error(#{gleam_error => panic,
message => <<"Invalid time in datetime literal value"/utf8>>,
module => <<"tempo/datetime"/utf8>>,
function => <<"literal"/utf8>>,
line => 105});
{error, _} ->
erlang:error(#{gleam_error => panic,
message => <<"Invalid datetime literal"/utf8>>,
module => <<"tempo/datetime"/utf8>>,
function => <<"literal"/utf8>>,
line => 106})
end.
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 231).
-spec to_string(tempo:date_time()) -> binary().
to_string(Datetime) ->
<<(begin
_pipe = Datetime,
_pipe@1 = tempo:datetime_get_naive(_pipe),
tempo@naive_datetime:to_string(_pipe@1)
end)/binary,
(case begin
_pipe@2 = Datetime,
_pipe@3 = tempo:datetime_get_offset(_pipe@2),
tempo:offset_get_minutes(_pipe@3)
end of
0 ->
<<"Z"/utf8>>;
_ ->
_pipe@4 = Datetime,
_pipe@5 = tempo:datetime_get_offset(_pipe@4),
tempo@offset:to_string(_pipe@5)
end)/binary>>.
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 271).
-spec parse(binary(), binary()) -> {ok, tempo:date_time()} |
{error, tempo:date_time_parse_error()}.
parse(Str, Fmt) ->
gleam@result:'try'(
begin
_pipe = tempo:consume_format(Str, Fmt),
gleam@result:replace_error(_pipe, date_time_invalid_format)
end,
fun(_use0) ->
{Parts, _} = _use0,
gleam@result:'try'(
begin
_pipe@1 = tempo:find_date(Parts),
gleam@result:map_error(
_pipe@1,
fun(E) -> {date_time_date_parse_error, E} end
)
end,
fun(Date) ->
gleam@result:'try'(
begin
_pipe@2 = tempo:find_time(Parts),
gleam@result:map_error(
_pipe@2,
fun(E@1) ->
{date_time_time_parse_error, E@1}
end
)
end,
fun(Time) ->
gleam@result:'try'(
begin
_pipe@3 = tempo:find_offset(Parts),
gleam@result:map_error(
_pipe@3,
fun(E@2) ->
{date_time_offset_parse_error, E@2}
end
)
end,
fun(Offset) -> {ok, new(Date, Time, Offset)} end
)
end
)
end
)
end
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 313).
-spec parse_any(binary()) -> {ok, tempo:date_time()} |
{error, tempo:date_time_parse_any_error()}.
parse_any(Str) ->
case tempo:parse_any(Str) of
{{some, Date}, {some, Time}, {some, Offset}} ->
{ok, new(Date, Time, Offset)};
{_, _, none} ->
{error, date_time_missing_offset};
{_, none, _} ->
{error, date_time_missing_time};
{none, _, _} ->
{error, date_time_missing_date}
end.
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 426).
-spec from_unix_utc(integer()) -> tempo:date_time().
from_unix_utc(Unix_ts) ->
new(
tempo@date:from_unix_utc(Unix_ts),
tempo@time:from_unix_utc(Unix_ts),
{offset, 0}
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 457).
-spec from_unix_milli_utc(integer()) -> tempo:date_time().
from_unix_milli_utc(Unix_ts) ->
new(
tempo@date:from_unix_milli_utc(Unix_ts),
tempo@time:from_unix_milli_utc(Unix_ts),
{offset, 0}
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 492).
-spec from_unix_micro_utc(integer()) -> tempo:date_time().
from_unix_micro_utc(Unix_ts) ->
new(
tempo@date:from_unix_micro_utc(Unix_ts),
tempo@time:from_unix_micro_utc(Unix_ts),
{offset, 0}
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 540).
-spec from_dynamic_string(gleam@dynamic:dynamic_()) -> {ok, tempo:date_time()} |
{error, list(gleam@dynamic:decode_error())}.
from_dynamic_string(Dynamic_string) ->
gleam@result:'try'(
gleam@dynamic:string(Dynamic_string),
fun(Dt) -> case from_string(Dt) of
{ok, Datetime} ->
{ok, Datetime};
{error, Tempo_error} ->
{error,
[{decode_error,
<<"tempo.DateTime"/utf8>>,
<<(case Tempo_error of
date_time_invalid_format ->
<<"Invalid format: "/utf8>>;
{date_time_time_parse_error,
{time_invalid_format, _}} ->
<<"Invalid time format: "/utf8>>;
{date_time_time_parse_error,
{time_out_of_bounds,
time_hour_out_of_bounds}} ->
<<"Invalid time hour value: "/utf8>>;
{date_time_time_parse_error,
{time_out_of_bounds,
time_minute_out_of_bounds}} ->
<<"Invalid time minute value: "/utf8>>;
{date_time_time_parse_error,
{time_out_of_bounds,
time_second_out_of_bounds}} ->
<<"Invalid time second value: "/utf8>>;
{date_time_time_parse_error,
{time_out_of_bounds,
time_nano_second_out_of_bounds}} ->
<<"Invalid time subsecond value: "/utf8>>;
{date_time_date_parse_error,
{date_invalid_format, _}} ->
<<"Invalid date format: "/utf8>>;
{date_time_date_parse_error,
{date_out_of_bounds,
date_day_out_of_bounds}} ->
<<"Invalid date day value: "/utf8>>;
{date_time_date_parse_error,
{date_out_of_bounds,
date_month_out_of_bounds}} ->
<<"Invalid date month value: "/utf8>>;
{date_time_date_parse_error,
{date_out_of_bounds,
date_year_out_of_bounds}} ->
<<"Invalid date year value: "/utf8>>;
{date_time_offset_parse_error,
{offset_invalid_format, _}} ->
<<"Invalid offset format: "/utf8>>;
{date_time_offset_parse_error,
offset_out_of_bounds} ->
<<"Invalid offset value: "/utf8>>
end)/binary, Dt/binary>>,
[]}]}
end end
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 612).
-spec from_dynamic_unix_utc(gleam@dynamic:dynamic_()) -> {ok, tempo:date_time()} |
{error, list(gleam@dynamic:decode_error())}.
from_dynamic_unix_utc(Dynamic_ts) ->
gleam@result:map(
gleam@dynamic:int(Dynamic_ts),
fun(Dt) -> from_unix_utc(Dt) end
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 642).
-spec from_dynamic_unix_milli_utc(gleam@dynamic:dynamic_()) -> {ok,
tempo:date_time()} |
{error, list(gleam@dynamic:decode_error())}.
from_dynamic_unix_milli_utc(Dynamic_ts) ->
gleam@result:map(
gleam@dynamic:int(Dynamic_ts),
fun(Dt) -> from_unix_milli_utc(Dt) end
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 672).
-spec from_dynamic_unix_micro_utc(gleam@dynamic:dynamic_()) -> {ok,
tempo:date_time()} |
{error, list(gleam@dynamic:decode_error())}.
from_dynamic_unix_micro_utc(Dynamic_ts) ->
gleam@result:map(
gleam@dynamic:int(Dynamic_ts),
fun(Dt) -> from_unix_micro_utc(Dt) end
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 689).
-spec get_date(tempo:date_time()) -> tempo:date().
get_date(Datetime) ->
_pipe = Datetime,
_pipe@1 = tempo:datetime_get_naive(_pipe),
tempo:naive_datetime_get_date(_pipe@1).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 702).
-spec get_time(tempo:date_time()) -> tempo:time().
get_time(Datetime) ->
_pipe = Datetime,
_pipe@1 = tempo:datetime_get_naive(_pipe),
tempo:naive_datetime_get_time(_pipe@1).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 715).
-spec get_offset(tempo:date_time()) -> tempo:offset().
get_offset(Datetime) ->
_pipe = Datetime,
tempo:datetime_get_offset(_pipe).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 393).
-spec replace_format(binary(), tempo:date_time()) -> binary().
replace_format(Content, Datetime) ->
Offset = begin
_pipe = Datetime,
get_offset(_pipe)
end,
case Content of
<<"z"/utf8>> ->
case begin
_pipe@1 = Offset,
tempo:offset_get_minutes(_pipe@1)
end of
0 ->
<<"Z"/utf8>>;
_ ->
Str_offset = begin
_pipe@2 = Offset,
tempo@offset:to_string(_pipe@2)
end,
case begin
_pipe@3 = Str_offset,
gleam@string:split(_pipe@3, <<":"/utf8>>)
end of
[Hours, <<"00"/utf8>>] ->
Hours;
_ ->
Str_offset
end
end;
<<"Z"/utf8>> ->
_pipe@4 = Offset,
tempo@offset:to_string(_pipe@4);
<<"ZZ"/utf8>> ->
_pipe@5 = Offset,
_pipe@6 = tempo@offset:to_string(_pipe@5),
gleam@string:replace(_pipe@6, <<":"/utf8>>, <<""/utf8>>);
_ ->
Content
end.
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 366).
-spec format(tempo:date_time(), binary()) -> binary().
format(Datetime, Fmt) ->
_assert_subject = gleam@regex:from_string(
<<"\\[([^\\]]+)\\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|z|SSSSS|SSSS|SSS|."/utf8>>
),
{ok, Re} = 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 => <<"tempo/datetime"/utf8>>,
function => <<"format"/utf8>>,
line => 367})
end,
_pipe = gleam@regex:scan(Re, Fmt),
_pipe@1 = lists:reverse(_pipe),
_pipe@7 = gleam@list:fold(_pipe@1, [], fun(Acc, Match) -> case Match of
{match, Content, []} ->
[begin
_pipe@2 = Content,
_pipe@4 = tempo@date:replace_format(
_pipe@2,
begin
_pipe@3 = Datetime,
get_date(_pipe@3)
end
),
_pipe@6 = tempo@time:replace_format(
_pipe@4,
begin
_pipe@5 = Datetime,
get_time(_pipe@5)
end
),
replace_format(_pipe@6, Datetime)
end |
Acc];
{match, _, [{some, Sub}]} ->
[Sub | Acc];
{match, Content@1, _} ->
[Content@1 | Acc]
end end),
gleam@string:join(_pipe@7, <<""/utf8>>).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 728).
-spec drop_offset(tempo:date_time()) -> tempo:naive_date_time().
drop_offset(Datetime) ->
tempo:datetime_drop_offset(Datetime).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 741).
-spec drop_time(tempo:date_time()) -> tempo:date_time().
drop_time(Datetime) ->
tempo:datetime(
tempo@naive_datetime:drop_time(
begin
_pipe = Datetime,
tempo:datetime_get_naive(_pipe)
end
),
begin
_pipe@1 = Datetime,
tempo:datetime_get_offset(_pipe@1)
end
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 759).
-spec apply_offset(tempo:date_time()) -> tempo:naive_date_time().
apply_offset(Datetime) ->
tempo:datetime_apply_offset(Datetime).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 439).
-spec to_unix_utc(tempo:date_time()) -> integer().
to_unix_utc(Datetime) ->
Utc_dt = begin
_pipe = Datetime,
apply_offset(_pipe)
end,
tempo@date:to_unix_utc(
begin
_pipe@1 = Utc_dt,
tempo:naive_datetime_get_date(_pipe@1)
end
)
+ (tempo:time_to_nanoseconds(
begin
_pipe@2 = Utc_dt,
tempo:naive_datetime_get_time(_pipe@2)
end
)
div 1000000000).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 474).
-spec to_unix_milli_utc(tempo:date_time()) -> integer().
to_unix_milli_utc(Datetime) ->
Utc_dt = begin
_pipe = Datetime,
apply_offset(_pipe)
end,
tempo@date:to_unix_milli_utc(
begin
_pipe@1 = Utc_dt,
tempo:naive_datetime_get_date(_pipe@1)
end
)
+ (tempo:time_to_nanoseconds(
begin
_pipe@2 = Utc_dt,
tempo:naive_datetime_get_time(_pipe@2)
end
)
div 1000000).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 509).
-spec to_unix_micro_utc(tempo:date_time()) -> integer().
to_unix_micro_utc(Datetime) ->
Utc_dt = begin
_pipe = Datetime,
apply_offset(_pipe)
end,
tempo@date:to_unix_micro_utc(
begin
_pipe@1 = Utc_dt,
tempo:naive_datetime_get_date(_pipe@1)
end
)
+ (tempo:time_to_nanoseconds(
begin
_pipe@2 = Utc_dt,
tempo:naive_datetime_get_time(_pipe@2)
end
)
div 1000).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 772).
-spec to_utc(tempo:date_time()) -> tempo:date_time().
to_utc(Datetime) ->
tempo:datetime_to_utc(Datetime).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 785).
-spec to_offset(tempo:date_time(), tempo:offset()) -> tempo:date_time().
to_offset(Datetime, Offset) ->
tempo:datetime_to_offset(Datetime, Offset).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 820).
-spec to_local(tempo:date_time()) -> tempo:uncertain_conversion(tempo:date_time()).
to_local(Datetime) ->
gleam@bool:lazy_guard(
begin
_pipe = Datetime,
tempo:datetime_get_offset(_pipe)
end
=:= tempo@offset:local(),
fun() -> {precise, Datetime} end,
fun() ->
Local_dt = begin
_pipe@1 = Datetime,
to_offset(_pipe@1, tempo@offset:local())
end,
case begin
_pipe@2 = Local_dt,
_pipe@3 = tempo:datetime_get_naive(_pipe@2),
tempo:naive_datetime_get_date(_pipe@3)
end
=:= tempo@date:current_local() of
true ->
{precise, Local_dt};
false ->
{imprecise, Local_dt}
end
end
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 121).
-spec now_local() -> tempo:date_time().
now_local() ->
case begin
_pipe = now_utc(),
to_local(_pipe)
end of
{precise, Datetime} ->
Datetime;
{imprecise, Datetime@1} ->
Datetime@1
end.
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 867).
-spec to_local_time(tempo:date_time()) -> tempo:uncertain_conversion(tempo:time()).
to_local_time(Datetime) ->
case to_local(Datetime) of
{precise, Datetime@1} ->
_pipe = Datetime@1,
_pipe@1 = tempo:datetime_get_naive(_pipe),
_pipe@2 = tempo:naive_datetime_get_time(_pipe@1),
{precise, _pipe@2};
{imprecise, Datetime@2} ->
_pipe@3 = Datetime@2,
_pipe@4 = tempo:datetime_get_naive(_pipe@3),
_pipe@5 = tempo:naive_datetime_get_time(_pipe@4),
{imprecise, _pipe@5}
end.
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 912).
-spec to_local_date(tempo:date_time()) -> tempo:uncertain_conversion(tempo:date()).
to_local_date(Datetime) ->
case to_local(Datetime) of
{precise, Datetime@1} ->
_pipe = Datetime@1,
_pipe@1 = tempo:datetime_get_naive(_pipe),
_pipe@2 = tempo:naive_datetime_get_date(_pipe@1),
{precise, _pipe@2};
{imprecise, Datetime@2} ->
_pipe@3 = Datetime@2,
_pipe@4 = tempo:datetime_get_naive(_pipe@3),
_pipe@5 = tempo:naive_datetime_get_date(_pipe@4),
{imprecise, _pipe@5}
end.
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 953).
-spec to_timezone(tempo:date_time(), tempo:time_zone_provider()) -> tempo:date_time().
to_timezone(Datetime, Tz) ->
tempo:datetime_to_tz(Datetime, Tz).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 978).
-spec get_timezone_name(tempo:date_time()) -> gleam@option:option(binary()).
get_timezone_name(Datetime) ->
tempo:datetime_get_tz(Datetime).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 1003).
-spec compare(tempo:date_time(), tempo:date_time()) -> gleam@order:order().
compare(A, B) ->
tempo:datetime_compare(A, B).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 1026).
-spec is_earlier(tempo:date_time(), tempo:date_time()) -> boolean().
is_earlier(A, B) ->
tempo:datetime_is_earlier(A, B).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 1048).
-spec is_earlier_or_equal(tempo:date_time(), tempo:date_time()) -> boolean().
is_earlier_or_equal(A, B) ->
tempo:datetime_is_earlier_or_equal(A, B).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 1070).
-spec is_equal(tempo:date_time(), tempo:date_time()) -> boolean().
is_equal(A, B) ->
compare(A, B) =:= eq.
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 1093).
-spec is_later(tempo:date_time(), tempo:date_time()) -> boolean().
is_later(A, B) ->
compare(A, B) =:= gt.
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 1115).
-spec is_later_or_equal(tempo:date_time(), tempo:date_time()) -> boolean().
is_later_or_equal(A, B) ->
tempo:datetime_is_later_or_equal(A, B).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 1141).
-spec difference(tempo:date_time(), tempo:date_time()) -> tempo:duration().
difference(A, B) ->
tempo@naive_datetime:difference(
tempo:datetime_apply_offset(A),
tempo:datetime_apply_offset(B)
).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 1175).
-spec as_period(tempo:date_time(), tempo:date_time()) -> tempo:period().
as_period(Start, End) ->
tempo:period_new(Start, End).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 1191).
-spec add(tempo:date_time(), tempo:duration()) -> tempo:date_time().
add(Datetime, Duration_to_add) ->
tempo:datetime_add(Datetime, Duration_to_add).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 1207).
-spec subtract(tempo:date_time(), tempo:duration()) -> tempo:date_time().
subtract(Datetime, Duration_to_subtract) ->
tempo:datetime_subtract(Datetime, Duration_to_subtract).
-file("/home/john/Repos/tempo/src/tempo/datetime.gleam", 1231).
-spec time_left_in_day(tempo:date_time()) -> tempo:time().
time_left_in_day(Datetime) ->
_pipe = Datetime,
_pipe@1 = tempo:datetime_get_naive(_pipe),
_pipe@2 = tempo:naive_datetime_get_time(_pipe@1),
tempo@time:left_in_day(_pipe@2).