* c-common.c (get_priority): Add check for
[official-gcc.git] / gcc / ada / a-calend-vms.ads
blob3f68ffb64684e7620cec4a2fcff4301548a086f6
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . C A L E N D A R --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
10 -- --
11 -- This specification is derived from the Ada Reference Manual for use with --
12 -- GNAT. The copyright notice above, and the license provisions that follow --
13 -- apply solely to the contents of the part following the private keyword. --
14 -- --
15 -- GNAT is free software; you can redistribute it and/or modify it under --
16 -- terms of the GNU General Public License as published by the Free Soft- --
17 -- ware Foundation; either version 2, or (at your option) any later ver- --
18 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
19 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
20 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
21 -- for more details. You should have received a copy of the GNU General --
22 -- Public License distributed with GNAT; see file COPYING. If not, write --
23 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
24 -- Boston, MA 02110-1301, USA. --
25 -- --
26 -- As a special exception, if other files instantiate generics from this --
27 -- unit, or you link this unit with other files to produce an executable, --
28 -- this unit does not by itself cause the resulting executable to be --
29 -- covered by the GNU General Public License. This exception does not --
30 -- however invalidate any other reasons why the executable file might be --
31 -- covered by the GNU Public License. --
32 -- --
33 -- GNAT was originally developed by the GNAT team at New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc. --
35 -- --
36 ------------------------------------------------------------------------------
38 -- This is the Alpha/VMS version
40 with System.OS_Primitives;
41 package Ada.Calendar is
43 package OSP renames System.OS_Primitives;
45 type Time is private;
47 -- Declarations representing limits of allowed local time values. Note that
48 -- these do NOT constrain the possible stored values of time which may well
49 -- permit a larger range of times (this is explicitly allowed in Ada 95).
51 subtype Year_Number is Integer range 1901 .. 2099;
52 subtype Month_Number is Integer range 1 .. 12;
53 subtype Day_Number is Integer range 1 .. 31;
55 subtype Day_Duration is Duration range 0.0 .. 86_400.0;
57 function Clock return Time;
59 function Year (Date : Time) return Year_Number;
60 function Month (Date : Time) return Month_Number;
61 function Day (Date : Time) return Day_Number;
62 function Seconds (Date : Time) return Day_Duration;
64 procedure Split
65 (Date : Time;
66 Year : out Year_Number;
67 Month : out Month_Number;
68 Day : out Day_Number;
69 Seconds : out Day_Duration);
71 function Time_Of
72 (Year : Year_Number;
73 Month : Month_Number;
74 Day : Day_Number;
75 Seconds : Day_Duration := 0.0)
76 return Time;
78 function "+" (Left : Time; Right : Duration) return Time;
79 function "+" (Left : Duration; Right : Time) return Time;
80 function "-" (Left : Time; Right : Duration) return Time;
81 function "-" (Left : Time; Right : Time) return Duration;
83 function "<" (Left, Right : Time) return Boolean;
84 function "<=" (Left, Right : Time) return Boolean;
85 function ">" (Left, Right : Time) return Boolean;
86 function ">=" (Left, Right : Time) return Boolean;
88 Time_Error : exception;
90 Unimplemented : exception;
92 private
94 pragma Inline (Clock);
96 pragma Inline (Year);
97 pragma Inline (Month);
98 pragma Inline (Day);
100 pragma Inline ("+");
101 pragma Inline ("-");
103 pragma Inline ("<");
104 pragma Inline ("<=");
105 pragma Inline (">");
106 pragma Inline (">=");
108 -- Time is represented as the number of 100-nanosecond (ns) units offset
109 -- from the system base date and time, which is 00:00 o'clock,
110 -- November 17, 1858 (the Smithsonian base date and time for the
111 -- astronomic calendar).
113 -- The time value stored is typically a GMT value, as provided in standard
114 -- Unix environments. If this is the case then Split and Time_Of perform
115 -- required conversions to and from local times.
117 type Time is new OSP.OS_Time;
119 -- Notwithstanding this definition, Time is not quite the same as OS_Time.
120 -- Relative Time is positive, whereas relative OS_Time is negative,
121 -- but this declaration makes for easier conversion.
123 -- The following package provides handling of leap seconds. It is
124 -- used by Ada.Calendar.Arithmetic and Ada.Calendar.Formatting, both
125 -- Ada 2005 children of Ada.Calendar.
127 package Leap_Sec_Ops is
129 After_Last_Leap : constant Time := Time'Last;
130 -- Bigger by far than any leap second value. Not within range of
131 -- Ada.Calendar specified dates.
133 procedure Cumulative_Leap_Secs
134 (Start_Date : Time;
135 End_Date : Time;
136 Leaps_Between : out Duration;
137 Next_Leap_Sec : out Time);
138 -- Leaps_Between is the sum of the leap seconds that have occured
139 -- on or after Start_Date and before (strictly before) End_Date.
140 -- Next_Leap_Sec represents the next leap second occurence on or
141 -- after End_Date. If there are no leaps seconds after End_Date,
142 -- After_Last_Leap is returned. This does not provide info about
143 -- the next leap second (pos/neg or ?). After_Last_Leap can be used
144 -- as End_Date to count all the leap seconds that have occured on
145 -- or after Start_Date.
147 -- Important Notes: any fractional parts of Start_Date and End_Date
148 -- are discarded before the calculations are done. For instance: if
149 -- 113 seconds is a leap second (it isn't) and 113.5 is input as an
150 -- End_Date, the leap second at 113 will not be counted in
151 -- Leaps_Between, but it will be returned as Next_Leap_Sec. Thus, if
152 -- the caller wants to know if the End_Date is a leap second, the
153 -- comparison should be:
155 -- End_Date >= Next_Leap_Sec;
157 -- After_Last_Leap is designed so that this comparison works without
158 -- having to first check if Next_Leap_Sec is a valid leap second.
160 function All_Leap_Seconds return Duration;
161 -- Returns the sum off all of the leap seoncds.
163 end Leap_Sec_Ops;
165 procedure Split_With_Offset
166 (Date : Time;
167 Year : out Year_Number;
168 Month : out Month_Number;
169 Day : out Day_Number;
170 Seconds : out Day_Duration;
171 Offset : out Long_Integer);
172 -- Split_W_Offset has the same spec as Split with the addition of an
173 -- offset value which give the offset of the local time zone from UTC
174 -- at the input Date. This value comes for free during the implementation
175 -- of Split and is needed by UTC_Time_Offset. The returned Offset time
176 -- is straight from the C tm struct and is in seconds. If the system
177 -- dependent code has no way to find the offset it will return the value
178 -- Invalid_TZ_Offset declared below. Otherwise no checking is done, so
179 -- it is up to the user to check both for Invalid_TZ_Offset and otherwise
180 -- for a value that is acceptable.
182 Invalid_TZ_Offset : Long_Integer;
183 pragma Import (C, Invalid_TZ_Offset, "__gnat_invalid_tzoff");
185 end Ada.Calendar;