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-2009 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 3, 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. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with Interfaces.C; use Interfaces.C;
34 package body Ada.Calendar.Conversions is
40 function To_Ada_Time (Unix_Time : long) return Time is
41 Val : constant Long_Integer := Long_Integer (Unix_Time);
43 return Conversion_Operations.To_Ada_Time (Val);
57 tm_isdst : int) return Time
59 Year : constant Integer := Integer (tm_year);
60 Month : constant Integer := Integer (tm_mon);
61 Day : constant Integer := Integer (tm_day);
62 Hour : constant Integer := Integer (tm_hour);
63 Minute : constant Integer := Integer (tm_min);
64 Second : constant Integer := Integer (tm_sec);
65 DST : constant Integer := Integer (tm_isdst);
68 Conversion_Operations.To_Ada_Time
69 (Year, Month, Day, Hour, Minute, Second, DST);
78 tv_nsec : long) return Duration
80 Secs : constant Long_Integer := Long_Integer (tv_sec);
81 Nano_Secs : constant Long_Integer := Long_Integer (tv_nsec);
83 return Conversion_Operations.To_Duration (Secs, Nano_Secs);
86 ------------------------
87 -- To_Struct_Timespec --
88 ------------------------
90 procedure To_Struct_Timespec
96 Nano_Secs : Long_Integer;
99 Conversion_Operations.To_Struct_Timespec (D, Secs, Nano_Secs);
101 tv_sec := long (Secs);
102 tv_nsec := long (Nano_Secs);
103 end To_Struct_Timespec;
109 procedure To_Struct_Tm
126 Conversion_Operations.To_Struct_Tm
127 (T, Year, Month, Day, Hour, Minute, Second);
129 tm_year := int (Year);
130 tm_mon := int (Month);
132 tm_hour := int (Hour);
133 tm_min := int (Minute);
134 tm_sec := int (Second);
141 function To_Unix_Time (Ada_Time : Time) return long is
142 Val : constant Long_Integer :=
143 Conversion_Operations.To_Unix_Time (Ada_Time);
148 end Ada.Calendar.Conversions;