public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1960] ada: Fix edge case in Ada.Calendar.Formatting.Time_Of Date: Tue, 20 Jun 2023 07:45:45 +0000 (GMT) [thread overview] Message-ID: <20230620074545.B0B3B3858D1E@sourceware.org> (raw) https://gcc.gnu.org/g:869216ec14be5c2be3136de1128b7f1acac3d87e commit r14-1960-g869216ec14be5c2be3136de1128b7f1acac3d87e Author: Ronan Desplanques <desplanques@adacore.com> Date: Tue May 23 09:07:50 2023 +0200 ada: Fix edge case in Ada.Calendar.Formatting.Time_Of Before this patch, Ada.Calendar.Formatting.Time_Of executed extra code when passed a number of seconds equal to the number of seconds in a day. This caused the result to be off, perhaps because a statement resetting the number of seconds to zero was missing. Instead of adding such a statement, this patch removes the special handling of the problematic case, which gives the intended result. gcc/ada/ * libgnat/a-calfor.adb (Time_Of): Fix handling of special case. Diff: --- gcc/ada/libgnat/a-calfor.adb | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/gcc/ada/libgnat/a-calfor.adb b/gcc/ada/libgnat/a-calfor.adb index 3325e562746..18f4e7388df 100644 --- a/gcc/ada/libgnat/a-calfor.adb +++ b/gcc/ada/libgnat/a-calfor.adb @@ -590,10 +590,6 @@ package body Ada.Calendar.Formatting is Leap_Second : Boolean := False; Time_Zone : Time_Zones.Time_Offset := 0) return Time is - Adj_Year : Year_Number := Year; - Adj_Month : Month_Number := Month; - Adj_Day : Day_Number := Day; - H : constant Integer := 1; M : constant Integer := 1; Se : constant Integer := 1; @@ -612,32 +608,11 @@ package body Ada.Calendar.Formatting is raise Constraint_Error; end if; - -- A Seconds value of 86_400 denotes a new day. This case requires an - -- adjustment to the input values. - - if Seconds = 86_400.0 then - if Day < Days_In_Month (Month) - or else (Is_Leap (Year) - and then Month = 2) - then - Adj_Day := Day + 1; - else - Adj_Day := 1; - - if Month < 12 then - Adj_Month := Month + 1; - else - Adj_Month := 1; - Adj_Year := Year + 1; - end if; - end if; - end if; - return Formatting_Operations.Time_Of - (Year => Adj_Year, - Month => Adj_Month, - Day => Adj_Day, + (Year => Year, + Month => Month, + Day => Day, Day_Secs => Seconds, Hour => H, Minute => M,
reply other threads:[~2023-06-20 7:45 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230620074545.B0B3B3858D1E@sourceware.org \ --to=dkm@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).