mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Use round/0 instead of ceil/0
Because ceil/0 was introduced in OTP20.0 only
This commit is contained in:
parent
9805b1a73a
commit
81ae691738
@ -417,12 +417,12 @@ time_before_expiration(Expiry) ->
|
|||||||
calendar:now_to_datetime(erlang:timestamp())),
|
calendar:now_to_datetime(erlang:timestamp())),
|
||||||
Secs = max(0, T1 - T2),
|
Secs = max(0, T1 - T2),
|
||||||
if Secs == {0, ""};
|
if Secs == {0, ""};
|
||||||
Secs >= 220752000 -> {ceil(Secs/220752000), "year"};
|
Secs >= 220752000 -> {round(Secs/220752000), "year"};
|
||||||
Secs >= 2592000 -> {ceil(Secs/2592000), "month"};
|
Secs >= 2592000 -> {round(Secs/2592000), "month"};
|
||||||
Secs >= 604800 -> {ceil(Secs/604800), "week"};
|
Secs >= 604800 -> {round(Secs/604800), "week"};
|
||||||
Secs >= 86400 -> {ceil(Secs/86400), "day"};
|
Secs >= 86400 -> {round(Secs/86400), "day"};
|
||||||
Secs >= 3600 -> {ceil(Secs/3600), "hour"};
|
Secs >= 3600 -> {round(Secs/3600), "hour"};
|
||||||
Secs >= 60 -> {ceil(Secs/60), "minute"};
|
Secs >= 60 -> {round(Secs/60), "minute"};
|
||||||
true -> {Secs, "second"}
|
true -> {Secs, "second"}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -430,8 +430,8 @@ time_before_expiration(Expiry) ->
|
|||||||
format_expiration_date(DateTime) ->
|
format_expiration_date(DateTime) ->
|
||||||
case time_before_expiration(DateTime) of
|
case time_before_expiration(DateTime) of
|
||||||
{0, _} -> "is expired";
|
{0, _} -> "is expired";
|
||||||
{1, Unit} -> "will expire in less than a " ++ Unit;
|
{1, Unit} -> "will expire in a " ++ Unit;
|
||||||
{Int, Unit} ->
|
{Int, Unit} ->
|
||||||
"will expire in less than " ++ integer_to_list(Int)
|
"will expire in " ++ integer_to_list(Int)
|
||||||
++ " " ++ Unit ++ "s"
|
++ " " ++ Unit ++ "s"
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user