2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / ada / a-calcon.ads
blobc0178a092a6b7ed83eb994e6e8081197750e33f4
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . C A L E N D A R . C O N V E R S I O N S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2008, Free Software Foundation, Inc. --
10 -- --
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. --
21 -- --
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. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This package provides various routines for conversion between Ada and Unix
35 -- time models - Time, Duration, struct tm and struct timespec.
37 with Interfaces.C;
39 package Ada.Calendar.Conversions is
41 function To_Ada_Time (Unix_Time : Interfaces.C.long) return Time;
42 -- Convert a time value represented as number of seconds since the Unix
43 -- Epoch to a time value relative to an Ada implementation-defined Epoch.
44 -- The units of the result are 100 nanoseconds on VMS and nanoseconds on
45 -- all other targets. Raises Time_Error if the result cannot fit into a
46 -- Time value.
48 function To_Ada_Time
49 (tm_year : Interfaces.C.int;
50 tm_mon : Interfaces.C.int;
51 tm_day : Interfaces.C.int;
52 tm_hour : Interfaces.C.int;
53 tm_min : Interfaces.C.int;
54 tm_sec : Interfaces.C.int;
55 tm_isdst : Interfaces.C.int) return Time;
56 -- Convert a time value expressed in Unix-like fields of struct tm into
57 -- a Time value relative to the Ada Epoch. The ranges of the formals are
58 -- as follows:
60 -- tm_year -- years since 1900
61 -- tm_mon -- months since January [0 .. 11]
62 -- tm_day -- day of the month [1 .. 31]
63 -- tm_hour -- hours since midnight [0 .. 24]
64 -- tm_min -- minutes after the hour [0 .. 59]
65 -- tm_sec -- seconds after the minute [0 .. 60]
66 -- tm_isdst -- Daylight Savings Time flag [-1 .. 1]
68 -- The returned value is in UTC and may or may not contain leap seconds
69 -- depending on whether binder flag "-y" was used. Raises Time_Error if
70 -- the input values are out of the defined ranges or if tm_sec equals 60
71 -- and the instance in time is not a leap second occurrence.
73 function To_Duration
74 (tv_sec : Interfaces.C.long;
75 tv_nsec : Interfaces.C.long) return Duration;
76 -- Convert an elapsed time value expressed in Unix-like fields of struct
77 -- timespec into a Duration value. The expected ranges are:
79 -- tv_sec - seconds
80 -- tv_nsec - nanoseconds
82 procedure To_Struct_Timespec
83 (D : Duration;
84 tv_sec : out Interfaces.C.long;
85 tv_nsec : out Interfaces.C.long);
86 -- Convert a Duration value into the constituents of struct timespec.
87 -- Formal tv_sec denotes seconds and tv_nsecs denotes nanoseconds.
89 procedure To_Struct_Tm
90 (T : Time;
91 tm_year : out Interfaces.C.int;
92 tm_mon : out Interfaces.C.int;
93 tm_day : out Interfaces.C.int;
94 tm_hour : out Interfaces.C.int;
95 tm_min : out Interfaces.C.int;
96 tm_sec : out Interfaces.C.int);
97 -- Convert a Time value set in the Ada Epoch into the constituents of
98 -- struct tm. The ranges of the out formals are as follows:
100 -- tm_year -- years since 1900
101 -- tm_mon -- months since January [0 .. 11]
102 -- tm_day -- day of the month [1 .. 31]
103 -- tm_hour -- hours since midnight [0 .. 24]
104 -- tm_min -- minutes after the hour [0 .. 59]
105 -- tm_sec -- seconds after the minute [0 .. 60]
106 -- tm_isdst -- Daylight Savings Time flag [-1 .. 1]
108 -- The input date is considered to be in UTC
110 function To_Unix_Time (Ada_Time : Time) return Interfaces.C.long;
111 -- Convert a time value represented as number of time units since the Ada
112 -- implementation-defined Epoch to a value relative to the Unix Epoch. The
113 -- units of the result are seconds. Raises Time_Error if the result cannot
114 -- fit into a Time value.
116 end Ada.Calendar.Conversions;