* c-decl.c (duplicate_decls): Conditionalize DECL_SAVED_TREE copy.
[official-gcc.git] / gcc / ada / g-calend.ads
blob16548db37064a63d59e445d594256ee243f4216f
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- G N A T . C A L E N D A R --
6 -- --
7 -- S p e c --
8 -- --
9 -- $Revision: 1.5 $
10 -- --
11 -- Copyright (C) 1999-2001 Free Software Foundation, Inc. --
12 -- --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
23 -- --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
30 -- --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
33 -- --
34 ------------------------------------------------------------------------------
36 -- This package extends Ada.Calendar to handle Hour, Minute, Second,
37 -- Second_Duration and Day_Of_Week and Day_In_Year from Calendar.Time.
38 -- Second_Duration precision depends on the target clock precision.
40 -- GNAT.Calendar provides the same kind of abstraction found in
41 -- Ada.Calendar. It provides Split and Time_Of to build and split a Time
42 -- data. And it provides accessor functions to get only one of Hour, Minute,
43 -- Second, Second_Duration. Other functions are to access more advanced
44 -- valueas like Day_Of_Week, Day_In_Year and Week_In_Year.
46 with Ada.Calendar;
47 with Interfaces.C;
49 package GNAT.Calendar is
51 type Day_Name is
52 (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
54 subtype Hour_Number is Natural range 0 .. 23;
55 subtype Minute_Number is Natural range 0 .. 59;
56 subtype Second_Number is Natural range 0 .. 59;
57 subtype Second_Duration is Ada.Calendar.Day_Duration range 0.0 .. 1.0;
58 subtype Day_In_Year_Number is Positive range 1 .. 366;
59 subtype Week_In_Year_Number is Positive range 1 .. 53;
61 function Hour (Date : Ada.Calendar.Time) return Hour_Number;
62 function Minute (Date : Ada.Calendar.Time) return Minute_Number;
63 function Second (Date : Ada.Calendar.Time) return Second_Number;
64 function Sub_Second (Date : Ada.Calendar.Time) return Second_Duration;
65 -- Hour, Minute, Sedond and Sub_Second returns the complete time data for
66 -- the Date (H:M:S.SS). See Ada.Calendar for Year, Month, Day accessors.
67 -- Second_Duration precision depends on the target clock precision.
69 function Day_Of_Week (Date : Ada.Calendar.Time) return Day_Name;
70 -- Return the day name.
72 function Day_In_Year (Date : Ada.Calendar.Time) return Day_In_Year_Number;
73 -- Returns the day number in the year. (1st January is day 1 and 31st
74 -- December is day 365 or 366 for leap year).
76 function Week_In_Year (Date : Ada.Calendar.Time) return Week_In_Year_Number;
77 -- Returns the week number in the year with Monday as first day of week
79 procedure Split
80 (Date : Ada.Calendar.Time;
81 Year : out Ada.Calendar.Year_Number;
82 Month : out Ada.Calendar.Month_Number;
83 Day : out Ada.Calendar.Day_Number;
84 Hour : out Hour_Number;
85 Minute : out Minute_Number;
86 Second : out Second_Number;
87 Sub_Second : out Second_Duration);
88 -- Split the standard Ada.Calendar.Time data in date data (Year, Month,
89 -- Day) and Time data (Hour, Minute, Second, Sub_Second)
91 function Time_Of
92 (Year : Ada.Calendar.Year_Number;
93 Month : Ada.Calendar.Month_Number;
94 Day : Ada.Calendar.Day_Number;
95 Hour : Hour_Number;
96 Minute : Minute_Number;
97 Second : Second_Number;
98 Sub_Second : Second_Duration := 0.0)
99 return Ada.Calendar.Time;
100 -- Returns an Ada.Calendar.Time data built from the date and time values.
102 -- C timeval conversion
104 -- C timeval represent a duration (used in Select for example). This
105 -- structure is composed of a number of seconds and a number of micro
106 -- seconds. The timeval structure is not exposed here because its
107 -- definition is target dependent. Interface to C programs is done via a
108 -- pointer to timeval structure.
110 type timeval is private;
112 function To_Duration (T : access timeval) return Duration;
113 function To_Timeval (D : Duration) return timeval;
115 private
116 -- This is a dummy declaration that should be the largest possible timeval
117 -- structure of all supported targets.
119 type timeval is array (1 .. 2) of Interfaces.C.long;
121 function Julian_Day
122 (Year : Ada.Calendar.Year_Number;
123 Month : Ada.Calendar.Month_Number;
124 Day : Ada.Calendar.Day_Number)
125 return Integer;
126 -- Compute Julian day number.
128 -- The code of this function is a modified version of algorithm
129 -- 199 from the Collected Algorithms of the ACM.
130 -- The author of algorithm 199 is Robert G. Tantzen.
131 end GNAT.Calendar;