1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . C A L E N D A R . C O N V E R S I O N S --
9 -- Copyright (C) 2008, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 with Interfaces.C; use Interfaces.C;
36 package body Ada.Calendar.Conversions is
42 function To_Ada_Time (Unix_Time : long) return Time is
43 Val : constant Long_Integer := Long_Integer (Unix_Time);
45 return Conversion_Operations.To_Ada_Time (Val);
59 tm_isdst : int) return Time
61 Year : constant Integer := Integer (tm_year);
62 Month : constant Integer := Integer (tm_mon);
63 Day : constant Integer := Integer (tm_day);
64 Hour : constant Integer := Integer (tm_hour);
65 Minute : constant Integer := Integer (tm_min);
66 Second : constant Integer := Integer (tm_sec);
67 DST : constant Integer := Integer (tm_isdst);
70 Conversion_Operations.To_Ada_Time
71 (Year, Month, Day, Hour, Minute, Second, DST);
80 tv_nsec : long) return Duration
82 Secs : constant Long_Integer := Long_Integer (tv_sec);
83 Nano_Secs : constant Long_Integer := Long_Integer (tv_nsec);
85 return Conversion_Operations.To_Duration (Secs, Nano_Secs);
88 ------------------------
89 -- To_Struct_Timespec --
90 ------------------------
92 procedure To_Struct_Timespec
98 Nano_Secs : Long_Integer;
101 Conversion_Operations.To_Struct_Timespec (D, Secs, Nano_Secs);
103 tv_sec := long (Secs);
104 tv_nsec := long (Nano_Secs);
105 end To_Struct_Timespec;
111 procedure To_Struct_Tm
128 Conversion_Operations.To_Struct_Tm
129 (T, Year, Month, Day, Hour, Minute, Second);
131 tm_year := int (Year);
132 tm_mon := int (Month);
134 tm_hour := int (Hour);
135 tm_min := int (Minute);
136 tm_sec := int (Second);
143 function To_Unix_Time (Ada_Time : Time) return long is
144 Val : constant Long_Integer :=
145 Conversion_Operations.To_Unix_Time (Ada_Time);
150 end Ada.Calendar.Conversions;