aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/a-calend.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2012-01-23 09:51:38 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2012-01-23 09:51:38 +0100
commit3ffd18f16ccb5256aaf5d8e6a55fc8ad2d521085 (patch)
treeca1029610d8618cd4042b4926c54ebe6c3185af8 /gcc/ada/a-calend.adb
parentce20f35b8f111d13784ac796abbf7dcc7720e9ae (diff)
downloadgcc-3ffd18f16ccb5256aaf5d8e6a55fc8ad2d521085.zip
gcc-3ffd18f16ccb5256aaf5d8e6a55fc8ad2d521085.tar.gz
gcc-3ffd18f16ccb5256aaf5d8e6a55fc8ad2d521085.tar.bz2
[multiple changes]
2012-01-23 Robert Dewar <dewar@adacore.com> * sprint.ads, sprint.adb (Sprint_Node_List): Add New_Lines parameter (pg,po,ps): Make sure each entry starts on new line. 2012-01-23 Hristian Kirtchev <kirtchev@adacore.com> * a-calend.ads, a-calend.adb: Define types int and int_Pointer. Update the parameter profile of procedure localtime_tzoff and its associated comment. (Day_Of_Week): Do not treat the input date as historical with respect to time zones. (Split): Do not treat the input date as historical with respect to time zones. (Time_Of): Do not treat the input constituents as forming a historical date with respect to time zones. (UTC_Time_Offset): Add new formal parameter Is_Historic. Add local variable Flag. Update the call to localtime_tzoff. * a-catizo.ads, a-catizo.adb (UTC_Time_Offset): New routine. (UTC_Time_Offset (Time)): Update the call to Time_Zone_Operations.UTC_Time_Offset. * sysdep.c (__gnat_localtime_tzoff): Update parameter profile. Split the processing of offsets on Windows into two - one part of historic time stamps and the other for the current time. From-SVN: r183413
Diffstat (limited to 'gcc/ada/a-calend.adb')
-rw-r--r--gcc/ada/a-calend.adb38
1 files changed, 30 insertions, 8 deletions
diff --git a/gcc/ada/a-calend.adb b/gcc/ada/a-calend.adb
index 8f541a0..f5fbbd5 100644
--- a/gcc/ada/a-calend.adb
+++ b/gcc/ada/a-calend.adb
@@ -1025,7 +1025,10 @@ package body Ada.Calendar is
function Day_Of_Week (Date : Time) return Integer is
Date_N : constant Time_Rep := Time_Rep (Date);
Time_Zone : constant Long_Integer :=
- Time_Zones_Operations.UTC_Time_Offset (Date);
+ Time_Zones_Operations.UTC_Time_Offset
+ (Date => Date,
+ Is_Historic => False);
+
Ada_Low_N : Time_Rep;
Day_Count : Long_Integer;
Day_Dur : Time_Dur;
@@ -1138,7 +1141,9 @@ package body Ada.Calendar is
else
declare
Off : constant Long_Integer :=
- Time_Zones_Operations.UTC_Time_Offset (Time (Date_N));
+ Time_Zones_Operations.UTC_Time_Offset
+ (Date => Time (Date_N),
+ Is_Historic => False);
begin
Date_N := Date_N + Time_Rep (Off) * Nano;
end;
@@ -1360,12 +1365,14 @@ package body Ada.Calendar is
declare
Current_Off : constant Long_Integer :=
Time_Zones_Operations.UTC_Time_Offset
- (Time (Res_N));
+ (Date => Time (Res_N),
+ Is_Historic => False);
Current_Res_N : constant Time_Rep :=
Res_N - Time_Rep (Current_Off) * Nano;
Off : constant Long_Integer :=
Time_Zones_Operations.UTC_Time_Offset
- (Time (Current_Res_N));
+ (Date => Time (Current_Res_N),
+ Is_Historic => False);
begin
Res_N := Res_N - Time_Rep (Off) * Nano;
end;
@@ -1438,7 +1445,9 @@ package body Ada.Calendar is
Nanos_In_56_Years : constant := (14 * 366 + 42 * 365) * Nanos_In_Day;
subtype long is Long_Integer;
+ subtype int is Integer;
type long_Pointer is access all long;
+ type int_Pointer is access all int;
type time_t is
range -(2 ** (Standard'Address_Size - Integer'(1))) ..
@@ -1446,21 +1455,28 @@ package body Ada.Calendar is
type time_t_Pointer is access all time_t;
procedure localtime_tzoff
- (timer : time_t_Pointer;
- off : long_Pointer);
+ (timer : time_t_Pointer;
+ is_historic : int_Pointer;
+ off : long_Pointer);
pragma Import (C, localtime_tzoff, "__gnat_localtime_tzoff");
-- This is a lightweight wrapper around the system library function
-- localtime_r. Parameter 'off' captures the UTC offset which is either
-- retrieved from the tm struct or calculated from the 'timezone' extern
- -- and the tm_isdst flag in the tm struct.
+ -- and the tm_isdst flag in the tm struct. Flag 'is_historic' denotes
+ -- whether 'timer' is a historical time stamp. If this is not the case,
+ -- the routine returns the offset of the local time zone.
---------------------
-- UTC_Time_Offset --
---------------------
- function UTC_Time_Offset (Date : Time) return Long_Integer is
+ function UTC_Time_Offset
+ (Date : Time;
+ Is_Historic : Boolean := True) return Long_Integer
+ is
Adj_Cent : Integer;
Date_N : Time_Rep;
+ Flag : aliased int;
Offset : aliased long;
Secs_T : aliased time_t;
@@ -1499,8 +1515,13 @@ package body Ada.Calendar is
Secs_T := time_t (Date_N / Nano);
+ -- Determine whether to treat the input date as historical or not
+
+ Flag := (if Is_Historic then 1 else 0);
+
localtime_tzoff
(Secs_T'Unchecked_Access,
+ Flag'Unchecked_Access,
Offset'Unchecked_Access);
return Offset;
@@ -1512,4 +1533,5 @@ package body Ada.Calendar is
begin
System.OS_Primitives.Initialize;
+
end Ada.Calendar;