OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [ada/] [g-calend.ads] - Blame information for rev 300

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
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
--          Copyright (C) 1999-2009, 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 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.                                     --
17
--                                                                          --
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.               --
21
--                                                                          --
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/>.                                          --
26
--                                                                          --
27
-- GNAT was originally developed  by the GNAT team at  New York University. --
28
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29
--                                                                          --
30
------------------------------------------------------------------------------
31
 
32
--  This package extends Ada.Calendar to handle Hour, Minute, Second,
33
--  Second_Duration and Day_Of_Week and Day_In_Year from Calendar.Time.
34
--  Second_Duration precision depends on the target clock precision.
35
--
36
--  GNAT.Calendar provides the same kind of abstraction found in
37
--  Ada.Calendar. It provides Split and Time_Of to build and split a Time
38
--  data. And it provides accessor functions to get only one of Hour, Minute,
39
--  Second, Second_Duration. Other functions are to access more advanced
40
--  values like Day_Of_Week, Day_In_Year and Week_In_Year.
41
 
42
with Ada.Calendar;
43
with Interfaces.C;
44
 
45
package GNAT.Calendar is
46
 
47
   type Day_Name is
48
     (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
49
 
50
   subtype Hour_Number         is Natural range 0 .. 23;
51
   subtype Minute_Number       is Natural range 0 .. 59;
52
   subtype Second_Number       is Natural range 0 .. 59;
53
   subtype Second_Duration     is Ada.Calendar.Day_Duration range 0.0 .. 1.0;
54
   subtype Day_In_Year_Number  is Positive range 1 .. 366;
55
   subtype Week_In_Year_Number is Positive range 1 .. 53;
56
 
57
   No_Time : constant Ada.Calendar.Time;
58
   --  A constant set to the first date that can be represented by the type
59
   --  Time. It can be used to indicate an uninitialized date.
60
 
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, Second 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.
68
 
69
   function Day_Of_Week (Date : Ada.Calendar.Time) return Day_Name;
70
   --  Return the day name
71
 
72
   function Day_In_Year (Date : Ada.Calendar.Time) return Day_In_Year_Number;
73
   --  Return the day number in the year. (1st January is day 1 and 31st
74
   --  December is day 365 or 366 for leap year).
75
 
76
   procedure Split
77
     (Date       : Ada.Calendar.Time;
78
      Year       : out Ada.Calendar.Year_Number;
79
      Month      : out Ada.Calendar.Month_Number;
80
      Day        : out Ada.Calendar.Day_Number;
81
      Hour       : out Hour_Number;
82
      Minute     : out Minute_Number;
83
      Second     : out Second_Number;
84
      Sub_Second : out Second_Duration);
85
   --  Split the standard Ada.Calendar.Time data in date data (Year, Month,
86
   --  Day) and Time data (Hour, Minute, Second, Sub_Second)
87
 
88
   function Time_Of
89
     (Year       : Ada.Calendar.Year_Number;
90
      Month      : Ada.Calendar.Month_Number;
91
      Day        : Ada.Calendar.Day_Number;
92
      Hour       : Hour_Number;
93
      Minute     : Minute_Number;
94
      Second     : Second_Number;
95
      Sub_Second : Second_Duration := 0.0) return Ada.Calendar.Time;
96
   --  Return an Ada.Calendar.Time data built from the date and time values
97
 
98
   function Week_In_Year (Date : Ada.Calendar.Time) return Week_In_Year_Number;
99
   --  Return the week number as defined in ISO 8601. A week always starts on
100
   --  a Monday and the first week of a particular year is the one containing
101
   --  the first Thursday. A year may have 53 weeks when January 1st is a
102
   --  Wednesday and the year is leap or January 1st is a Thursday. Note that
103
   --  the last days of December may belong to the first week on the next year
104
   --  and conversely, the first days of January may belong to the last week
105
   --  of the last year.
106
 
107
   procedure Year_Week_In_Year
108
     (Date : Ada.Calendar.Time;
109
      Year : out Ada.Calendar.Year_Number;
110
      Week : out Week_In_Year_Number);
111
   --  Return the week number as defined in ISO 8601 along with the year in
112
   --  which the week occurs.
113
 
114
   --  C timeval conversion
115
 
116
   --  C timeval represent a duration (used in Select for example). This
117
   --  structure is composed of a number of seconds and a number of micro
118
   --  seconds. The timeval structure is not exposed here because its
119
   --  definition is target dependent. Interface to C programs is done via a
120
   --  pointer to timeval structure.
121
 
122
   type timeval is private;
123
 
124
   function To_Duration (T : not null access timeval) return Duration;
125
   function To_Timeval  (D : Duration) return timeval;
126
 
127
private
128
   --  This is a dummy declaration that should be the largest possible timeval
129
   --  structure of all supported targets.
130
 
131
   type timeval is array (1 .. 2) of Interfaces.C.long;
132
 
133
   function Julian_Day
134
     (Year  : Ada.Calendar.Year_Number;
135
      Month : Ada.Calendar.Month_Number;
136
      Day   : Ada.Calendar.Day_Number) return Integer;
137
   --  Compute Julian day number
138
   --
139
   --  The code of this function is a modified version of algorithm 199 from
140
   --  the Collected Algorithms of the ACM. The author of algorithm 199 is
141
   --  Robert G. Tantzen.
142
 
143
   No_Time : constant Ada.Calendar.Time :=
144
               Ada.Calendar.Time_Of
145
                 (Ada.Calendar.Year_Number'First,
146
                  Ada.Calendar.Month_Number'First,
147
                  Ada.Calendar.Day_Number'First);
148
 
149
end GNAT.Calendar;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.