From ece8d66cdcd9caea3a80da63200fe73953ff076d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D0=BB=D0=BE=D0=BC=D0=B0=D1=82=D0=B8=D0=BD=20?= =?UTF-8?q?=D0=90=D1=80=D1=82=D0=B5=D0=BC=20=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB?= =?UTF-8?q?=D0=B0=D0=B5=D0=B2=D0=B8=D1=87?= Date: Sat, 18 Nov 2023 18:55:28 +0300 Subject: [PATCH] Fix --- modules/65-extra/10-dates-and-times/lib/solution.ex | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/65-extra/10-dates-and-times/lib/solution.ex b/modules/65-extra/10-dates-and-times/lib/solution.ex index 2f4445a..811340b 100644 --- a/modules/65-extra/10-dates-and-times/lib/solution.ex +++ b/modules/65-extra/10-dates-and-times/lib/solution.ex @@ -7,11 +7,11 @@ defmodule Solution do def shift_days(time, 0), do: time def shift_days(%Time{} = time, amount) when is_integer(amount) do - Time.add(time, amount * 24, :hour) + Time.add(time, days_to_seconds(amount) * 24, :second) end def shift_days(%NaiveDateTime{} = time, amount) when is_integer(amount) do - NaiveDateTime.add(time, amount, :day) + NaiveDateTime.add(time, days_to_seconds(amount), :second) end def shift_days(%Date{} = time, amount) when is_integer(amount) do @@ -19,7 +19,11 @@ defmodule Solution do end def shift_days(%DateTime{} = time, amount) when is_integer(amount) do - DateTime.add(time, amount, :day) + DateTime.add(time, days_to_seconds(amount), :second) + end + + defp days_to_seconds(amount) do + amount * 24 * 60 * 60 end # END