annotate gcc/ada/libgnat/a-calfor.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- A D A . C A L E N D A R . F O R M A T T I N G --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2005-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- This specification is derived from the Ada Reference Manual for use with --
kono
parents:
diff changeset
12 -- GNAT. In accordance with the copyright of that document, you can freely --
kono
parents:
diff changeset
13 -- copy and modify this specification, provided that if you redistribute a --
kono
parents:
diff changeset
14 -- modified version, any changes that you have made are clearly indicated. --
kono
parents:
diff changeset
15 -- --
kono
parents:
diff changeset
16 ------------------------------------------------------------------------------
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 -- This package provides additional components to Time, as well as new
kono
parents:
diff changeset
19 -- Time_Of and Split routines which handle time zones and leap seconds.
kono
parents:
diff changeset
20 -- This package is defined in the Ada 2005 RM (9.6.1).
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 with Ada.Calendar.Time_Zones;
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 package Ada.Calendar.Formatting is
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- Day of the week
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 type Day_Name is
kono
parents:
diff changeset
29 (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 function Day_Of_Week (Date : Time) return Day_Name;
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 -- Hours:Minutes:Seconds access
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 subtype Hour_Number is Natural range 0 .. 23;
kono
parents:
diff changeset
36 subtype Minute_Number is Natural range 0 .. 59;
kono
parents:
diff changeset
37 subtype Second_Number is Natural range 0 .. 59;
kono
parents:
diff changeset
38 subtype Second_Duration is Day_Duration range 0.0 .. 1.0;
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 function Year
kono
parents:
diff changeset
41 (Date : Time;
kono
parents:
diff changeset
42 Time_Zone : Time_Zones.Time_Offset := 0) return Year_Number;
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 function Month
kono
parents:
diff changeset
45 (Date : Time;
kono
parents:
diff changeset
46 Time_Zone : Time_Zones.Time_Offset := 0) return Month_Number;
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 function Day
kono
parents:
diff changeset
49 (Date : Time;
kono
parents:
diff changeset
50 Time_Zone : Time_Zones.Time_Offset := 0) return Day_Number;
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 function Hour
kono
parents:
diff changeset
53 (Date : Time;
kono
parents:
diff changeset
54 Time_Zone : Time_Zones.Time_Offset := 0) return Hour_Number;
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 function Minute
kono
parents:
diff changeset
57 (Date : Time;
kono
parents:
diff changeset
58 Time_Zone : Time_Zones.Time_Offset := 0) return Minute_Number;
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 function Second
kono
parents:
diff changeset
61 (Date : Time) return Second_Number;
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 function Sub_Second
kono
parents:
diff changeset
64 (Date : Time) return Second_Duration;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 function Seconds_Of
kono
parents:
diff changeset
67 (Hour : Hour_Number;
kono
parents:
diff changeset
68 Minute : Minute_Number;
kono
parents:
diff changeset
69 Second : Second_Number := 0;
kono
parents:
diff changeset
70 Sub_Second : Second_Duration := 0.0) return Day_Duration;
kono
parents:
diff changeset
71 -- Returns a Day_Duration value for the combination of the given Hour,
kono
parents:
diff changeset
72 -- Minute, Second, and Sub_Second. This value can be used in Ada.Calendar.
kono
parents:
diff changeset
73 -- Time_Of as well as the argument to Calendar."+" and Calendar."-". If
kono
parents:
diff changeset
74 -- Seconds_Of is called with a Sub_Second value of 1.0, the value returned
kono
parents:
diff changeset
75 -- is equal to the value of Seconds_Of for the next second with a Sub_
kono
parents:
diff changeset
76 -- Second value of 0.0.
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 procedure Split
kono
parents:
diff changeset
79 (Seconds : Day_Duration;
kono
parents:
diff changeset
80 Hour : out Hour_Number;
kono
parents:
diff changeset
81 Minute : out Minute_Number;
kono
parents:
diff changeset
82 Second : out Second_Number;
kono
parents:
diff changeset
83 Sub_Second : out Second_Duration);
kono
parents:
diff changeset
84 -- Splits Seconds into Hour, Minute, Second and Sub_Second in such a way
kono
parents:
diff changeset
85 -- that the resulting values all belong to their respective subtypes. The
kono
parents:
diff changeset
86 -- value returned in the Sub_Second parameter is always less than 1.0.
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 procedure Split
kono
parents:
diff changeset
89 (Date : Time;
kono
parents:
diff changeset
90 Year : out Year_Number;
kono
parents:
diff changeset
91 Month : out Month_Number;
kono
parents:
diff changeset
92 Day : out Day_Number;
kono
parents:
diff changeset
93 Hour : out Hour_Number;
kono
parents:
diff changeset
94 Minute : out Minute_Number;
kono
parents:
diff changeset
95 Second : out Second_Number;
kono
parents:
diff changeset
96 Sub_Second : out Second_Duration;
kono
parents:
diff changeset
97 Time_Zone : Time_Zones.Time_Offset := 0);
kono
parents:
diff changeset
98 -- Splits Date into its constituent parts (Year, Month, Day, Hour, Minute,
kono
parents:
diff changeset
99 -- Second, Sub_Second), relative to the specified time zone offset. The
kono
parents:
diff changeset
100 -- value returned in the Sub_Second parameter is always less than 1.0.
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 function Time_Of
kono
parents:
diff changeset
103 (Year : Year_Number;
kono
parents:
diff changeset
104 Month : Month_Number;
kono
parents:
diff changeset
105 Day : Day_Number;
kono
parents:
diff changeset
106 Hour : Hour_Number;
kono
parents:
diff changeset
107 Minute : Minute_Number;
kono
parents:
diff changeset
108 Second : Second_Number;
kono
parents:
diff changeset
109 Sub_Second : Second_Duration := 0.0;
kono
parents:
diff changeset
110 Leap_Second : Boolean := False;
kono
parents:
diff changeset
111 Time_Zone : Time_Zones.Time_Offset := 0) return Time;
kono
parents:
diff changeset
112 -- If Leap_Second is False, returns a Time built from the date and time
kono
parents:
diff changeset
113 -- values, relative to the specified time zone offset. If Leap_Second is
kono
parents:
diff changeset
114 -- True, returns the Time that represents the time within the leap second
kono
parents:
diff changeset
115 -- that is one second later than the time specified by the parameters.
kono
parents:
diff changeset
116 -- Time_Error is raised if the parameters do not form a proper date or
kono
parents:
diff changeset
117 -- time. If Time_Of is called with a Sub_Second value of 1.0, the value
kono
parents:
diff changeset
118 -- returned is equal to the value of Time_Of for the next second with a
kono
parents:
diff changeset
119 -- Sub_Second value of 0.0.
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 function Time_Of
kono
parents:
diff changeset
122 (Year : Year_Number;
kono
parents:
diff changeset
123 Month : Month_Number;
kono
parents:
diff changeset
124 Day : Day_Number;
kono
parents:
diff changeset
125 Seconds : Day_Duration := 0.0;
kono
parents:
diff changeset
126 Leap_Second : Boolean := False;
kono
parents:
diff changeset
127 Time_Zone : Time_Zones.Time_Offset := 0) return Time;
kono
parents:
diff changeset
128 -- If Leap_Second is False, returns a Time built from the date and time
kono
parents:
diff changeset
129 -- values, relative to the specified time zone offset. If Leap_Second is
kono
parents:
diff changeset
130 -- True, returns the Time that represents the time within the leap second
kono
parents:
diff changeset
131 -- that is one second later than the time specified by the parameters.
kono
parents:
diff changeset
132 -- Time_Error is raised if the parameters do not form a proper date or
kono
parents:
diff changeset
133 -- time. If Time_Of is called with a Seconds value of 86_400.0, the value
kono
parents:
diff changeset
134 -- returned is equal to the value of Time_Of for the next day with a
kono
parents:
diff changeset
135 -- Seconds value of 0.0.
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 procedure Split
kono
parents:
diff changeset
138 (Date : Time;
kono
parents:
diff changeset
139 Year : out Year_Number;
kono
parents:
diff changeset
140 Month : out Month_Number;
kono
parents:
diff changeset
141 Day : out Day_Number;
kono
parents:
diff changeset
142 Hour : out Hour_Number;
kono
parents:
diff changeset
143 Minute : out Minute_Number;
kono
parents:
diff changeset
144 Second : out Second_Number;
kono
parents:
diff changeset
145 Sub_Second : out Second_Duration;
kono
parents:
diff changeset
146 Leap_Second : out Boolean;
kono
parents:
diff changeset
147 Time_Zone : Time_Zones.Time_Offset := 0);
kono
parents:
diff changeset
148 -- If Date does not represent a time within a leap second, splits Date
kono
parents:
diff changeset
149 -- into its constituent parts (Year, Month, Day, Hour, Minute, Second,
kono
parents:
diff changeset
150 -- Sub_Second), relative to the specified time zone offset, and sets
kono
parents:
diff changeset
151 -- Leap_Second to False. If Date represents a time within a leap second,
kono
parents:
diff changeset
152 -- set the constituent parts to values corresponding to a time one second
kono
parents:
diff changeset
153 -- earlier than that given by Date, relative to the specified time zone
kono
parents:
diff changeset
154 -- offset, and sets Leap_Seconds to True. The value returned in the
kono
parents:
diff changeset
155 -- Sub_Second parameter is always less than 1.0.
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 procedure Split
kono
parents:
diff changeset
158 (Date : Time;
kono
parents:
diff changeset
159 Year : out Year_Number;
kono
parents:
diff changeset
160 Month : out Month_Number;
kono
parents:
diff changeset
161 Day : out Day_Number;
kono
parents:
diff changeset
162 Seconds : out Day_Duration;
kono
parents:
diff changeset
163 Leap_Second : out Boolean;
kono
parents:
diff changeset
164 Time_Zone : Time_Zones.Time_Offset := 0);
kono
parents:
diff changeset
165 -- If Date does not represent a time within a leap second, splits Date
kono
parents:
diff changeset
166 -- into its constituent parts (Year, Month, Day, Seconds), relative to the
kono
parents:
diff changeset
167 -- specified time zone offset, and sets Leap_Second to False. If Date
kono
parents:
diff changeset
168 -- represents a time within a leap second, set the constituent parts to
kono
parents:
diff changeset
169 -- values corresponding to a time one second earlier than that given by
kono
parents:
diff changeset
170 -- Date, relative to the specified time zone offset, and sets Leap_Seconds
kono
parents:
diff changeset
171 -- to True. The value returned in the Seconds parameter is always less
kono
parents:
diff changeset
172 -- than 86_400.0.
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 -- Simple image and value
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 function Image
kono
parents:
diff changeset
177 (Date : Time;
kono
parents:
diff changeset
178 Include_Time_Fraction : Boolean := False;
kono
parents:
diff changeset
179 Time_Zone : Time_Zones.Time_Offset := 0) return String;
kono
parents:
diff changeset
180 -- Returns a string form of the Date relative to the given Time_Zone. The
kono
parents:
diff changeset
181 -- format is "Year-Month-Day Hour:Minute:Second", where the Year is a
kono
parents:
diff changeset
182 -- 4-digit value, and all others are 2-digit values, of the functions
kono
parents:
diff changeset
183 -- defined in Ada.Calendar and Ada.Calendar.Formatting, including a
kono
parents:
diff changeset
184 -- leading zero, if needed. The separators between the values are a minus,
kono
parents:
diff changeset
185 -- another minus, a colon, and a single space between the Day and Hour. If
kono
parents:
diff changeset
186 -- Include_Time_Fraction is True, the integer part of Sub_Seconds*100 is
kono
parents:
diff changeset
187 -- suffixed to the string as a point followed by a 2-digit value.
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 function Value
kono
parents:
diff changeset
190 (Date : String;
kono
parents:
diff changeset
191 Time_Zone : Time_Zones.Time_Offset := 0) return Time;
kono
parents:
diff changeset
192 -- Returns a Time value for the image given as Date, relative to the given
kono
parents:
diff changeset
193 -- time zone. Constraint_Error is raised if the string is not formatted as
kono
parents:
diff changeset
194 -- described for Image, or the function cannot interpret the given string
kono
parents:
diff changeset
195 -- as a Time value.
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 function Image
kono
parents:
diff changeset
198 (Elapsed_Time : Duration;
kono
parents:
diff changeset
199 Include_Time_Fraction : Boolean := False) return String;
kono
parents:
diff changeset
200 -- Returns a string form of the Elapsed_Time. The format is "Hour:Minute:
kono
parents:
diff changeset
201 -- Second", where all values are 2-digit values, including a leading zero,
kono
parents:
diff changeset
202 -- if needed. The separators between the values are colons. If Include_
kono
parents:
diff changeset
203 -- Time_Fraction is True, the integer part of Sub_Seconds*100 is suffixed
kono
parents:
diff changeset
204 -- to the string as a point followed by a 2-digit value. If Elapsed_Time <
kono
parents:
diff changeset
205 -- 0.0, the result is Image (abs Elapsed_Time, Include_Time_Fraction)
kono
parents:
diff changeset
206 -- prefixed with a minus sign. If abs Elapsed_Time represents 100 hours or
kono
parents:
diff changeset
207 -- more, the result is implementation-defined.
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 function Value (Elapsed_Time : String) return Duration;
kono
parents:
diff changeset
210 -- Returns a Duration value for the image given as Elapsed_Time.
kono
parents:
diff changeset
211 -- Constraint_Error is raised if the string is not formatted as described
kono
parents:
diff changeset
212 -- for Image, or the function cannot interpret the given string as a
kono
parents:
diff changeset
213 -- Duration value.
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 end Ada.Calendar.Formatting;