return Conversion_Operations.To_Ada_Time (Val);
end To_Ada_Time;
+ --------------------
+ -- To_Ada_Time_64 --
+ --------------------
+
+ function To_Ada_Time_64 (Unix_Time : long_long) return Time is
+ Val : constant Long_Long_Integer := Long_Long_Integer (Unix_Time);
+ begin
+ return Conversion_Operations.To_Ada_Time_64 (Val);
+ end To_Ada_Time_64;
+
-----------------
-- To_Ada_Time --
-----------------
return Conversion_Operations.To_Duration (Secs, Nano_Secs);
end To_Duration;
+ --------------------
+ -- To_Duration_64 --
+ --------------------
+
+ function To_Duration_64
+ (tv_sec : long_long;
+ tv_nsec : long) return Duration
+ is
+ Secs : constant Long_Long_Integer := Long_Long_Integer (tv_sec);
+ Nano_Secs : constant Long_Integer := Long_Integer (tv_nsec);
+ begin
+ return Conversion_Operations.To_Duration_64 (Secs, Nano_Secs);
+ end To_Duration_64;
+
------------------------
-- To_Struct_Timespec --
------------------------
tv_nsec := long (Nano_Secs);
end To_Struct_Timespec;
+ ---------------------------
+ -- To_Struct_Timespec_64 --
+ ---------------------------
+
+ procedure To_Struct_Timespec_64
+ (D : Duration;
+ tv_sec : out long_long;
+ tv_nsec : out long)
+ is
+ Secs : Long_Long_Integer;
+ Nano_Secs : Long_Integer;
+
+ begin
+ Conversion_Operations.To_Struct_Timespec_64 (D, Secs, Nano_Secs);
+
+ tv_sec := long_long (Secs);
+ tv_nsec := long (Nano_Secs);
+ end To_Struct_Timespec_64;
+
------------------
-- To_Struct_Tm --
------------------
return long (Val);
end To_Unix_Time;
+ ---------------------
+ -- To_Unix_Time_64 --
+ ---------------------
+
+ function To_Unix_Time_64 (Ada_Time : Time) return long_long is
+ Val : constant Long_Long_Integer :=
+ Conversion_Operations.To_Unix_Time_64 (Ada_Time);
+ begin
+ return long_long (Val);
+ end To_Unix_Time_64;
+
-----------------------
-- To_Unix_Nano_Time --
-----------------------
package Ada.Calendar.Conversions is
function To_Ada_Time (Unix_Time : Interfaces.C.long) return Time;
+ pragma Obsolescent (To_Ada_Time, "Retires in v26");
+ -- Old version which will overflow at the 2038 Epochalypse
+
+ function To_Ada_Time_64 (Unix_Time : Interfaces.C.long_long) return Time;
-- Convert a time value represented as number of seconds since the
-- Unix Epoch to a time value relative to an Ada implementation-defined
-- Epoch. The units of the result are nanoseconds on all targets. Raises
function To_Duration
(tv_sec : Interfaces.C.long;
tv_nsec : Interfaces.C.long) return Duration;
+ pragma Obsolescent (To_Duration, "Retires in v26");
+ -- Old version which will overflow at the 2038 Epochalypse
+
+ function To_Duration_64
+ (tv_sec : Interfaces.C.long_long;
+ tv_nsec : Interfaces.C.long) return Duration;
-- Convert an elapsed time value expressed in Unix-like fields of struct
-- timespec into a Duration value. The expected ranges are:
(D : Duration;
tv_sec : out Interfaces.C.long;
tv_nsec : out Interfaces.C.long);
+ pragma Obsolescent (To_Struct_Timespec, "Retires in v26");
+ -- Old version which will overflow at the 2038 Epochalypse
+
+ procedure To_Struct_Timespec_64
+ (D : Duration;
+ tv_sec : out Interfaces.C.long_long;
+ tv_nsec : out Interfaces.C.long);
-- Convert a Duration value into the constituents of struct timespec.
-- Formal tv_sec denotes seconds and tv_nsecs denotes nanoseconds.
-- The input date is considered to be in UTC
function To_Unix_Time (Ada_Time : Time) return Interfaces.C.long;
+ pragma Obsolescent (To_Unix_Time, "Retires in v26");
+ -- Old version which will overflow at the 2038 Epochalypse
+
+ function To_Unix_Time_64 (Ada_Time : Time) return Interfaces.C.long_long;
-- Convert a time value represented as number of time units since the Ada
-- implementation-defined Epoch to a value relative to the Unix Epoch. The
-- units of the result are seconds. Raises Time_Error if the result cannot
-----------------
function To_Ada_Time (Unix_Time : Long_Integer) return Time is
+ begin
+ return To_Ada_Time_64 (Long_Long_Integer (Unix_Time));
+ end To_Ada_Time;
+
+ --------------------
+ -- To_Ada_Time_64 --
+ --------------------
+
+ function To_Ada_Time_64 (Unix_Time : Long_Long_Integer) return Time is
pragma Unsuppress (Overflow_Check);
Ada_Rep : Time_Rep := Time_Rep (Unix_Time * Nano) - Epoch_Offset;
exception
when Constraint_Error =>
raise Time_Error;
- end To_Ada_Time;
+ end To_Ada_Time_64;
-----------------
-- To_Ada_Time --
function To_Duration
(tv_sec : Long_Integer;
tv_nsec : Long_Integer) return Duration
+ is
+ begin
+ return To_Duration_64 (Long_Long_Integer (tv_sec), tv_nsec);
+ end To_Duration;
+
+ --------------------
+ -- To_Duration_64 --
+ --------------------
+
+ function To_Duration_64
+ (tv_sec : Long_Long_Integer;
+ tv_nsec : Long_Integer) return Duration
is
pragma Unsuppress (Overflow_Check);
begin
return Duration (tv_sec) + Duration (tv_nsec) / Nano_F;
- end To_Duration;
+ end To_Duration_64;
------------------------
-- To_Struct_Timespec --
(D : Duration;
tv_sec : out Long_Integer;
tv_nsec : out Long_Integer)
+ is
+ begin
+ To_Struct_Timespec_64 (D, Long_Long_Integer (tv_sec), tv_nsec);
+ end To_Struct_Timespec;
+
+ ---------------------------
+ -- To_Struct_Timespec_64 --
+ ---------------------------
+
+ procedure To_Struct_Timespec_64
+ (D : Duration;
+ tv_sec : out Long_Long_Integer;
+ tv_nsec : out Long_Integer)
is
pragma Unsuppress (Overflow_Check);
Secs : Duration;
-- Seconds extraction, avoid potential rounding errors
Secs := D - 0.5;
- tv_sec := Long_Integer (Secs);
+ tv_sec := Long_Long_Integer (Secs);
-- Nanoseconds extraction
Nano_Secs := D - Duration (tv_sec);
tv_nsec := Long_Integer (Nano_Secs * Nano);
- end To_Struct_Timespec;
+ end To_Struct_Timespec_64;
------------------
-- To_Struct_Tm --
------------------
function To_Unix_Time (Ada_Time : Time) return Long_Integer is
+ begin
+ return Long_Integer (To_Unix_Time_64 (Ada_Time));
+ end To_Unix_Time;
+
+ ---------------------
+ -- To_Unix_Time_64 --
+ ---------------------
+
+ function To_Unix_Time_64 (Ada_Time : Time) return Long_Long_Integer is
pragma Unsuppress (Overflow_Check);
Ada_Rep : constant Time_Rep := Time_Rep (Ada_Time);
begin
- return Long_Integer ((Ada_Rep + Epoch_Offset) / Nano) -
- Long_Integer (Elapsed_Leaps (Start_Of_Time, Ada_Rep));
+ return Long_Long_Integer ((Ada_Rep + Epoch_Offset) / Nano) -
+ Long_Long_Integer (Elapsed_Leaps (Start_Of_Time, Ada_Rep));
exception
when Constraint_Error =>
raise Time_Error;
- end To_Unix_Time;
+ end To_Unix_Time_64;
end Conversion_Operations;
----------------------
package Conversion_Operations is
function To_Ada_Time (Unix_Time : Long_Integer) return Time;
+ pragma Obsolescent (To_Ada_Time, "Retires in v26");
+ -- Old Unix to Ada Epoch conversion
+
+ function To_Ada_Time_64 (Unix_Time : Long_Long_Integer) return Time;
-- Unix to Ada Epoch conversion
function To_Ada_Time
function To_Duration
(tv_sec : Long_Integer;
tv_nsec : Long_Integer) return Duration;
+ pragma Obsolescent (To_Duration, "Retires in v26");
+ -- Old Struct timespec to Duration conversion
+
+ function To_Duration_64
+ (tv_sec : Long_Long_Integer;
+ tv_nsec : Long_Integer) return Duration;
-- Struct timespec to Duration conversion
procedure To_Struct_Timespec
(D : Duration;
tv_sec : out Long_Integer;
tv_nsec : out Long_Integer);
+ pragma Obsolescent (To_Struct_Timespec, "Retires in v26");
+ -- Old Duration to struct timespec conversion
+
+ procedure To_Struct_Timespec_64
+ (D : Duration;
+ tv_sec : out Long_Long_Integer;
+ tv_nsec : out Long_Integer);
-- Duration to struct timespec conversion
procedure To_Struct_Tm
-- Time to struct tm conversion
function To_Unix_Time (Ada_Time : Time) return Long_Integer;
+ pragma Obsolescent (To_Unix_Time, "Retires in v26");
+ -- Old Ada to Unix Epoch conversion
+
+ function To_Unix_Time_64 (Ada_Time : Time) return Long_Long_Integer;
-- Ada to Unix Epoch conversion
end Conversion_Operations;