Current section

Files

Jump to
gtempo src tempo@duration.erl
Raw

src/tempo@duration.erl

-module(tempo@duration).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([format/1, format_as/3, format_as_many/3, years_imprecise/1, weeks/1, days/1, hours/1, minutes/1, seconds/1, milliseconds/1, microseconds/1, new/2, increase/2, decrease/2, as_unit/2, as_unit_fractional/2, as_years_imprecise/1, as_years_fractional_imprecise/1, as_weeks/1, as_weeks_fractional/1, as_days/1, as_days_fractional/1, as_hours/1, as_hours_fractional/1, as_minutes/1, as_minutes_fractional/1, as_seconds/1, as_seconds_fractional/1, as_milliseconds/1, as_milliseconds_fractional/1, as_microseconds/1, as_microseconds_fractional/1, compare/2, is_less/2, is_less_or_equal/2, is_equal/2, is_greater/2, is_greater_or_equal/2, absolute/1, inverse/1, is_negative/1]).
-export_type([unit/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Functions to use with the `Duration` type in Tempo.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" import gleam/io\n"
" import tempo/duration\n"
" import tempo/time\n"
" \n"
" pub fn main() {\n"
" time.literal(\"01:42:11\")\n"
" |> time.since(time.literal(\"00:00:01\"))\n"
" |> duration.format\n"
" // -> \"1 hour, 42 minutes, 10 seconds\"\n"
" }\n"
" ```\n"
).
-type unit() :: year_imprecise |
week |
day |
hour |
minute |
second |
millisecond |
microsecond.
-file("src/tempo/duration.gleam", 84).
?DOC(
" Formats the duration as a string, inferring the units to use.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.microseconds(172_980_000_000)\n"
" |> duration.format\n"
" // -> \"2 days, 0 hours, and 3 minutes\"\n"
" ```\n"
" \n"
" ```gleam\n"
" duration.seconds(691_332_000_000)\n"
" |> duration.format\n"
" // -> \"1 week, 1 day, 0 hours, and 2 minutes\"\n"
" ```\n"
).
-spec format(gleam@time@duration:duration()) -> binary().
format(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:format(_pipe@1).
-file("src/tempo/duration.gleam", 99).
-spec as_internal_unit(unit()) -> gtempo@internal:unit().
as_internal_unit(U) ->
case U of
year_imprecise ->
year;
week ->
week;
day ->
day;
hour ->
hour;
minute ->
minute;
second ->
second;
millisecond ->
millisecond;
microsecond ->
microsecond
end.
-file("src/tempo/duration.gleam", 34).
?DOC(
" Formats the duration as the specified unit with the specified number \n"
" of decimals.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.minutes(1)\n"
" |> duration.format_as(duration.Second, decimals: 3)\n"
" // -> \"60.000 minutes\"\n"
" ```\n"
).
-spec format_as(gleam@time@duration:duration(), unit(), integer()) -> binary().
format_as(Duration, Unit, Decimals) ->
_pipe = as_internal_unit(Unit),
gtempo@internal:format_as(
begin
_pipe@1 = Duration,
tempo:duration_get_microseconds(_pipe@1)
end,
_pipe,
Decimals
).
-file("src/tempo/duration.gleam", 56).
?DOC(
" Formats the duration as the specified units, with the last unit having\n"
" the specified number of decimals.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.milliseconds(100_303)\n"
" |> duration.format_as_many(\n"
" [duration.Minute, duration.Second],\n"
" decimals: 2,\n"
" )\n"
" // -> \"1 minute and 40.30 seconds\"\n"
" ```\n"
).
-spec format_as_many(gleam@time@duration:duration(), list(unit()), integer()) -> binary().
format_as_many(Duration, Units, Decimals) ->
_pipe = gleam@list:map(Units, fun as_internal_unit/1),
gtempo@internal:format_as_many(
begin
_pipe@1 = Duration,
tempo:duration_get_microseconds(_pipe@1)
end,
_pipe,
Decimals
).
-file("src/tempo/duration.gleam", 144).
?DOC(
" Creates a new duration value of the specified number of whole years,\n"
" assuming a year is 365 days.\n"
"\n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.years_imprecise(1)\n"
" |> duration.format\n"
" // -> \"1 ~year\"\n"
" ```\n"
).
-spec years_imprecise(integer()) -> gleam@time@duration:duration().
years_imprecise(Years) ->
_pipe = Years,
_pipe@1 = gtempo@internal:imprecise_years(_pipe),
tempo:duration_microseconds(_pipe@1).
-file("src/tempo/duration.gleam", 157).
?DOC(
" Creates a new duration value of the specified number of whole weeks.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.weeks(3)\n"
" |> duration.format\n"
" // -> \"3 weeks\"\n"
" ```\n"
).
-spec weeks(integer()) -> gleam@time@duration:duration().
weeks(Weeks) ->
_pipe = Weeks,
_pipe@1 = gtempo@internal:imprecise_weeks(_pipe),
tempo:duration_microseconds(_pipe@1).
-file("src/tempo/duration.gleam", 170).
?DOC(
" Creates a new duration value of the specified number of whole days.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(3)\n"
" |> duration.format_as(duration.Hour, decimals: 0)\n"
" // -> \"36 hours\"\n"
" ```\n"
).
-spec days(integer()) -> gleam@time@duration:duration().
days(Days) ->
tempo:duration_days(Days).
-file("src/tempo/duration.gleam", 183).
?DOC(
" Creates a new duration value of the specified number of whole hours.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.hours(13)\n"
" |> duration.format\n"
" // -> \"13 hours, 0 minutes, 0.0 seconds\"\n"
" ```\n"
).
-spec hours(integer()) -> gleam@time@duration:duration().
hours(Hours) ->
_pipe = Hours,
_pipe@1 = gtempo@internal:hours(_pipe),
tempo:duration_microseconds(_pipe@1).
-file("src/tempo/duration.gleam", 196).
?DOC(
" Creates a new duration value of the specified number of whole minutes.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.minutes(13)\n"
" |> duration.format\n"
" // -> \"13 minutes and 0.0 seconds\"\n"
" ```\n"
).
-spec minutes(integer()) -> gleam@time@duration:duration().
minutes(Minutes) ->
tempo:duration_minutes(Minutes).
-file("src/tempo/duration.gleam", 210).
?DOC(
" Creates a new duration value of the specified number of whole seconds.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.minutes(1)\n"
" |> duration.increase(by: duration.seconds(13))\n"
" |> duration.format_as(duration.Second, decimals: 0)\n"
" // -> \"73 seconds\"\n"
" ```\n"
).
-spec seconds(integer()) -> gleam@time@duration:duration().
seconds(Seconds) ->
_pipe = Seconds,
_pipe@1 = gtempo@internal:seconds(_pipe),
tempo:duration_microseconds(_pipe@1).
-file("src/tempo/duration.gleam", 224).
?DOC(
" Creates a new duration value of the specified number of whole milliseconds.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.seconds(1)\n"
" |> duration.increase(by: duration.milliseconds(13))\n"
" |> duration.format_as(duration.Millisecond, decimals: 0)\n"
" // -> \"113 milliseconds\"\n"
" ```\n"
).
-spec milliseconds(integer()) -> gleam@time@duration:duration().
milliseconds(Milliseconds) ->
_pipe = Milliseconds,
_pipe@1 = gtempo@internal:milliseconds(_pipe),
tempo:duration_microseconds(_pipe@1).
-file("src/tempo/duration.gleam", 238).
?DOC(
" Creates a new duration value of the specified number of whole microseconds.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.milliseconds(1)\n"
" |> duration.increase(by: duration.microseconds(13))\n"
" |> duration.format_as(duration.Microsecond, decimals: 0)\n"
" // -> \"113 microseconds\"\n"
" ```\n"
).
-spec microseconds(integer()) -> gleam@time@duration:duration().
microseconds(Microseconds) ->
_pipe = Microseconds,
tempo:duration_microseconds(_pipe).
-file("src/tempo/duration.gleam", 121).
?DOC(
" Creates a new duration from the value and unit provided.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.new(100, duration.Millisecond)\n"
" |> duration.as_seconds_fractional\n"
" // -> 0.0000001\n"
" ```\n"
).
-spec new(integer(), unit()) -> gleam@time@duration:duration().
new(Duration, Unit) ->
case Unit of
year_imprecise ->
years_imprecise(Duration);
week ->
weeks(Duration);
day ->
days(Duration);
hour ->
hours(Duration);
minute ->
minutes(Duration);
second ->
seconds(Duration);
millisecond ->
milliseconds(Duration);
microsecond ->
microseconds(Duration)
end.
-file("src/tempo/duration.gleam", 253).
?DOC(
" Increases a duration by the specified duration. If a negative value is \n"
" passed, the duration will be decreased.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.increase(by: duration.days(6))\n"
" |> duration.format_as(duration.Day, decimals: 0)\n"
" // -> \"7 days\"\n"
" ```\n"
).
-spec increase(gleam@time@duration:duration(), gleam@time@duration:duration()) -> gleam@time@duration:duration().
increase(A, B) ->
tempo:duration_increase(A, B).
-file("src/tempo/duration.gleam", 279).
?DOC(
" Decreases a duration by the specified duration. If a negative value is \n"
" passed, the duration will be increased.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.decrease(by: duration.days(6))\n"
" |> duration.format_as(duration.Day, decimals: 0)\n"
" // -> \"-5 days\"\n"
" ```\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.decrease(by: duration.days(6))\n"
" |> duration.abosulte\n"
" |> duration.format_as(duration.Day, decimals: 0)\n"
" // -> \"5 days\"\n"
" ```\n"
).
-spec decrease(gleam@time@duration:duration(), gleam@time@duration:duration()) -> gleam@time@duration:duration().
decrease(A, B) ->
tempo:duration_decrease(A, B).
-file("src/tempo/duration.gleam", 295).
?DOC(
" Converts a duration to the specified whole units.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.minutes(1)\n"
" |> duration.as_unit(duration.Second)\n"
" // -> 60\n"
" ```\n"
).
-spec as_unit(gleam@time@duration:duration(), unit()) -> integer().
as_unit(Duration, Unit) ->
_pipe = as_internal_unit(Unit),
gtempo@internal:as_unit(
begin
_pipe@1 = Duration,
tempo:duration_get_microseconds(_pipe@1)
end,
_pipe
).
-file("src/tempo/duration.gleam", 309).
?DOC(
" Converts a duration to the specified fractional units.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(8)\n"
" |> duration.as_unit_fractional(duration.Week)\n"
" // -> 1.142857143\n"
" ```\n"
).
-spec as_unit_fractional(gleam@time@duration:duration(), unit()) -> float().
as_unit_fractional(Duration, Unit) ->
_pipe = as_internal_unit(Unit),
gtempo@internal:as_unit_fractional(
begin
_pipe@1 = Duration,
tempo:duration_get_microseconds(_pipe@1)
end,
_pipe
).
-file("src/tempo/duration.gleam", 324).
?DOC(
" Converts a duration to the equivalent number of whole years, assuming \n"
" a year is 365 days.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(375)\n"
" |> duration.as_years_imprecise\n"
" // -> 1\n"
" ```\n"
).
-spec as_years_imprecise(gleam@time@duration:duration()) -> integer().
as_years_imprecise(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_years_imprecise(_pipe@1).
-file("src/tempo/duration.gleam", 338).
?DOC(
" Converts a duration to the equivalent number of fractional years, \n"
" assuming a year is 365 days.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(375)\n"
" |> duration.as_years_fractional_imprecise\n"
" // -> 1.02739726\n"
" ```\n"
).
-spec as_years_fractional_imprecise(gleam@time@duration:duration()) -> float().
as_years_fractional_imprecise(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_years_imprecise_fractional(_pipe@1).
-file("src/tempo/duration.gleam", 345).
?DOC(" Converts a duration to the equivalent number of whole weeks.\n").
-spec as_weeks(gleam@time@duration:duration()) -> integer().
as_weeks(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_weeks_imprecise(_pipe@1).
-file("src/tempo/duration.gleam", 350).
?DOC(" Converts a duration to the equivalent number of fractional weeks.\n").
-spec as_weeks_fractional(gleam@time@duration:duration()) -> float().
as_weeks_fractional(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_weeks_imprecise_fractional(_pipe@1).
-file("src/tempo/duration.gleam", 357).
?DOC(" Converts a duration to the equivalent number of whole days.\n").
-spec as_days(gleam@time@duration:duration()) -> integer().
as_days(Duration) ->
tempo:duration_as_days(Duration).
-file("src/tempo/duration.gleam", 362).
?DOC(" Converts a duration to the equivalent number of fractional days.\n").
-spec as_days_fractional(gleam@time@duration:duration()) -> float().
as_days_fractional(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_days_fractional(_pipe@1).
-file("src/tempo/duration.gleam", 367).
?DOC(" Converts a duration to the equivalent number of whole hours.\n").
-spec as_hours(gleam@time@duration:duration()) -> integer().
as_hours(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_hours(_pipe@1).
-file("src/tempo/duration.gleam", 372).
?DOC(" Converts a duration to the equivalent number of fractional hours.\n").
-spec as_hours_fractional(gleam@time@duration:duration()) -> float().
as_hours_fractional(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_hours_fractional(_pipe@1).
-file("src/tempo/duration.gleam", 377).
?DOC(" Converts a duration to the equivalent number of whole minutes.\n").
-spec as_minutes(gleam@time@duration:duration()) -> integer().
as_minutes(Duration) ->
tempo:duration_as_mintues(Duration).
-file("src/tempo/duration.gleam", 382).
?DOC(" Converts a duration to the equivalent number of fractional minutes.\n").
-spec as_minutes_fractional(gleam@time@duration:duration()) -> float().
as_minutes_fractional(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_minutes_fractional(_pipe@1).
-file("src/tempo/duration.gleam", 387).
?DOC(" Converts a duration to the equivalent number of whole seconds.\n").
-spec as_seconds(gleam@time@duration:duration()) -> integer().
as_seconds(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_seconds(_pipe@1).
-file("src/tempo/duration.gleam", 392).
?DOC(" Converts a duration to the equivalent number of fractional seconds.\n").
-spec as_seconds_fractional(gleam@time@duration:duration()) -> float().
as_seconds_fractional(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_seconds_fractional(_pipe@1).
-file("src/tempo/duration.gleam", 397).
?DOC(" Converts a duration to the equivalent number of whole milliseconds.\n").
-spec as_milliseconds(gleam@time@duration:duration()) -> integer().
as_milliseconds(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_milliseconds(_pipe@1).
-file("src/tempo/duration.gleam", 402).
?DOC(" Converts a duration to the equivalent number of fractional milliseconds.\n").
-spec as_milliseconds_fractional(gleam@time@duration:duration()) -> float().
as_milliseconds_fractional(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_milliseconds_fractional(_pipe@1).
-file("src/tempo/duration.gleam", 407).
?DOC(" Converts a duration to the equivalent number of whole microseconds.\n").
-spec as_microseconds(gleam@time@duration:duration()) -> integer().
as_microseconds(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_microseconds(_pipe@1).
-file("src/tempo/duration.gleam", 413).
?DOC(
" Converts a duration to the equivalent number of fractional microseconds.\n"
" Microseconds are the smallest unit of time that are used in this package.\n"
).
-spec as_microseconds_fractional(gleam@time@duration:duration()) -> float().
as_microseconds_fractional(Duration) ->
_pipe = Duration,
_pipe@1 = tempo:duration_get_microseconds(_pipe),
gtempo@internal:as_microseconds_fractional(_pipe@1).
-file("src/tempo/duration.gleam", 432).
?DOC(
" Compares two durations.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.compare(to: duration.days(1))\n"
" // -> order.Eq\n"
" ```\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.compare(to: duration.days(2))\n"
" // -> order.Lt\n"
" ```\n"
).
-spec compare(gleam@time@duration:duration(), gleam@time@duration:duration()) -> gleam@order:order().
compare(A, B) ->
gleam@time@duration:compare(A, B).
-file("src/tempo/duration.gleam", 451).
?DOC(
" Checks if a duration is less than another duration.\n"
"\n"
" ## Example\n"
"\n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.is_less(than: duration.hours(25))\n"
" // -> True\n"
" ```\n"
"\n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.is_less(than: duration.days(1))\n"
" // -> False\n"
" ```\n"
).
-spec is_less(gleam@time@duration:duration(), gleam@time@duration:duration()) -> boolean().
is_less(A, B) ->
gleam@time@duration:compare(A, B) =:= lt.
-file("src/tempo/duration.gleam", 470).
?DOC(
" Checks if a duration is less than or equal to another duration.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.is_less_or_equal(to: duration.days(2))\n"
" // -> True\n"
" ```\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.is_less_or_equal(to: duration.days(1))\n"
" // -> True\n"
" ```\n"
).
-spec is_less_or_equal(
gleam@time@duration:duration(),
gleam@time@duration:duration()
) -> boolean().
is_less_or_equal(A, B) ->
(gleam@time@duration:compare(A, B) =:= lt) orelse (gleam@time@duration:compare(
A,
B
)
=:= eq).
-file("src/tempo/duration.gleam", 489).
?DOC(
" Checks if a duration is equal to another duration.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.weeks(1)\n"
" |> duration.is_equal(to: duration.days(7))\n"
" // -> True\n"
" ```\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.is_equal(to: duration.days(2))\n"
" // -> False\n"
" ```\n"
).
-spec is_equal(gleam@time@duration:duration(), gleam@time@duration:duration()) -> boolean().
is_equal(A, B) ->
gleam@time@duration:compare(A, B) =:= eq.
-file("src/tempo/duration.gleam", 508).
?DOC(
" Checks if a duration is greater than another duration.\n"
"\n"
" ## Example\n"
"\n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.is_greater(than: duration.days(2))\n"
" // -> False\n"
" ```\n"
"\n"
" ```gleam\n"
" duration.weeks(1)\n"
" |> duration.is_greater(than: duration.days(1))\n"
" // -> True\n"
" ```\n"
).
-spec is_greater(gleam@time@duration:duration(), gleam@time@duration:duration()) -> boolean().
is_greater(A, B) ->
gleam@time@duration:compare(A, B) =:= gt.
-file("src/tempo/duration.gleam", 527).
?DOC(
" Checks if a duration is greater than or equal to another duration.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.is_greater_or_equal(to: duration.days(2))\n"
" // -> False\n"
" ```\n"
" \n"
" ```gleam\n"
" duration.seconds(60)\n"
" |> duration.is_greater_or_equal(to: duration.minutes(1))\n"
" // -> True\n"
" ```\n"
).
-spec is_greater_or_equal(
gleam@time@duration:duration(),
gleam@time@duration:duration()
) -> boolean().
is_greater_or_equal(A, B) ->
(gleam@time@duration:compare(A, B) =:= gt) orelse (gleam@time@duration:compare(
A,
B
)
=:= eq).
-file("src/tempo/duration.gleam", 545).
?DOC(
" Returns the absolute value of a duration.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.decrease(by: duration.days(6))\n"
" |> duration.abosulte\n"
" |> duration.format_as(duration.Day, decimals: 0)\n"
" // -> \"5 days\"\n"
" ```\n"
).
-spec absolute(gleam@time@duration:duration()) -> gleam@time@duration:duration().
absolute(Duration) ->
tempo:duration_absolute(Duration).
-file("src/tempo/duration.gleam", 560).
?DOC(
" Returns the inverse of a duration.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.inverse\n"
" |> duration.format_as(duration.Day, decimals: 0)\n"
" // -> \"-1 days\"\n"
" ```\n"
).
-spec inverse(gleam@time@duration:duration()) -> gleam@time@duration:duration().
inverse(Duration) ->
tempo:duration_inverse(Duration).
-file("src/tempo/duration.gleam", 584).
?DOC(
" Checks if a duration is negative.\n"
" \n"
" ## Example\n"
" \n"
" ```gleam\n"
" duration.days(1)\n"
" |> duration.is_negative\n"
" // -> False\n"
" ```\n"
" \n"
" ```gleam\n"
" case \n"
" time.literal(\"13:42:05\")\n"
" |> time.difference(from: time.literal(\"13:42:10\"))\n"
" |> duration.is_negative\n"
" {\n"
" True -> \"we are ahead of time!\"\n"
" False -> \"We are either on time or late!\"\n"
" }\n"
" ```\n"
).
-spec is_negative(gleam@time@duration:duration()) -> boolean().
is_negative(Duration) ->
not tempo:duration_is_positive(Duration).