diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-11-30 14:52:35 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-11-30 14:52:35 +0100 |
commit | c5ff22e7b3ffc1e45b043e1bd35bb3b0bad90817 (patch) | |
tree | b7abf5afcd58c6232f9fa433485530fc11d00ab7 /gcc/ada/a-calend.adb | |
parent | 226e989e7e81f44758f112c719f16d93ccf8be19 (diff) | |
download | gcc-c5ff22e7b3ffc1e45b043e1bd35bb3b0bad90817.zip gcc-c5ff22e7b3ffc1e45b043e1bd35bb3b0bad90817.tar.gz gcc-c5ff22e7b3ffc1e45b043e1bd35bb3b0bad90817.tar.bz2 |
[multiple changes]
2009-11-30 Thomas Quinot <quinot@adacore.com>
* put_scos.adb (Put_SCOs): Do not generate a SCO unit header for a unit
that has no SCOs.
* scos.ads: Minor reformatting
2009-11-30 Ed Schonberg <schonberg@adacore.com>
* sem_prag.adb: Second unanalyzed parameter of Annotate is optional.
2009-11-30 Eric Botcazou <ebotcazou@adacore.com>
* init.c (__gnat_adjust_context_for_raise, Linux version): Add guard
for null PC saved in the context.
2009-11-30 Hristian Kirtchev <kirtchev@adacore.com>
* a-calend.adb (Day_Of_Week): Rewritten. The routine determines the
number of days from the Ada Epoch to the input date while ensuring that
both dates are in the same time zone.
From-SVN: r154801
Diffstat (limited to 'gcc/ada/a-calend.adb')
-rw-r--r-- | gcc/ada/a-calend.adb | 71 |
1 files changed, 24 insertions, 47 deletions
diff --git a/gcc/ada/a-calend.adb b/gcc/ada/a-calend.adb index 1a49c58..dd500f4 100644 --- a/gcc/ada/a-calend.adb +++ b/gcc/ada/a-calend.adb @@ -1029,63 +1029,40 @@ package body Ada.Calendar is ----------------- function Day_Of_Week (Date : Time) return Integer is - Y : Year_Number; - Mo : Month_Number; - D : Day_Number; - Ds : Day_Duration; - H : Integer; - Mi : Integer; - Se : Integer; - Su : Duration; - Le : Boolean; - - pragma Unreferenced (Ds, H, Mi, Se, Su, Le); + Date_N : constant Time_Rep := Time_Rep (Date); + Time_Zone : constant Long_Integer := + Time_Zones_Operations.UTC_Time_Offset (Date); + Ada_Low_N : Time_Rep; Day_Count : Long_Integer; - Res_Dur : Time_Dur; - Res_N : Time_Rep; + Day_Dur : Time_Dur; + High_N : Time_Rep; + Low_N : Time_Rep; begin - Formatting_Operations.Split - (Date => Date, - Year => Y, - Month => Mo, - Day => D, - Day_Secs => Ds, - Hour => H, - Minute => Mi, - Second => Se, - Sub_Sec => Su, - Leap_Sec => Le, - Is_Ada_05 => True, - Time_Zone => 0); - - -- Build a time value in the middle of the same day - - Res_N := - Time_Rep - (Formatting_Operations.Time_Of - (Year => Y, - Month => Mo, - Day => D, - Day_Secs => 0.0, - Hour => 12, - Minute => 0, - Second => 0, - Sub_Sec => 0.0, - Leap_Sec => False, - Use_Day_Secs => False, - Is_Ada_05 => True, - Time_Zone => 0)); + -- As declared, the Ada Epoch is set in UTC. For this calculation to + -- work properly, both the Epoch and the input date must be in the + -- same time zone. The following places the Epoch in the input date's + -- time zone. + + Ada_Low_N := Ada_Low - Time_Rep (Time_Zone) * Nano; + + if Date_N > Ada_Low_N then + High_N := Date_N; + Low_N := Ada_Low_N; + else + High_N := Ada_Low_N; + Low_N := Date_N; + end if; -- Determine the elapsed seconds since the start of Ada time - Res_Dur := Time_Dur (Res_N / Nano - Ada_Low / Nano); + Day_Dur := Time_Dur (High_N / Nano - Low_N / Nano); - -- Count the number of days since the start of Ada time. 1901-1-1 + -- Count the number of days since the start of Ada time. 1901-01-01 -- GMT was a Tuesday. - Day_Count := Long_Integer (Res_Dur / Secs_In_Day) + 1; + Day_Count := Long_Integer (Day_Dur / Secs_In_Day) + 1; return Integer (Day_Count mod 7); end Day_Of_Week; |