OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [g-calend.ads] - Blame information for rev 729

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

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

powered by: WebSVN 2.1.0

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