~ubuntu-branches/debian/stretch/adabrowse/stretch

« back to all changes in this revision

Viewing changes to util-calendar.ads

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Brenta
  • Date: 2004-02-14 13:22:40 UTC
  • Revision ID: james.westby@ubuntu.com-20040214132240-cqumhiq1677pkvzo
Tags: upstream-4.0.2
ImportĀ upstreamĀ versionĀ 4.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-------------------------------------------------------------------------------
 
2
--
 
3
--  <STRONG>Copyright &copy; 2001, 2002 by Thomas Wolf.</STRONG>
 
4
--  <BLOCKQUOTE>
 
5
--    This piece of software is free software; you can redistribute it and/or
 
6
--    modify it under the terms of the  GNU General Public License as published
 
7
--    by the Free Software  Foundation; either version 2, or (at your option)
 
8
--    any later version. This software is distributed in the hope that it will
 
9
--    be useful, but <EM>without any warranty</EM>; without even the implied
 
10
--    warranty of <EM>merchantability or fitness for a particular purpose.</EM>
 
11
--    See the GNU General Public License for  more details. You should have
 
12
--    received a copy of the GNU General Public License with this distribution,
 
13
--    see file "<A HREF="GPL.txt">GPL.txt</A>". If not, write to the Free
 
14
--    Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 
15
--    USA.
 
16
--  </BLOCKQUOTE>
 
17
--  <BLOCKQUOTE>
 
18
--    As a special exception from the GPL, if other files instantiate generics
 
19
--    from this unit, or you link this unit with other files to produce an
 
20
--    executable, this unit does not by itself cause the resulting executable
 
21
--    to be covered by the GPL. This exception does not however invalidate any
 
22
--    other reasons why the executable file might be covered by the GPL.
 
23
--  </BLOCKQUOTE>
 
24
--
 
25
--  <AUTHOR>
 
26
--    Thomas Wolf  (TW) <E_MAIL>
 
27
--  </AUTHOR>
 
28
--
 
29
--  <PURPOSE>
 
30
--    Root package of the calendar subsystem. Provides a day-of-week
 
31
--    calculation for Gregorian dates.
 
32
--  </PURPOSE>
 
33
--
 
34
--  <DL><DT><STRONG>Literature:</STRONG><DD>
 
35
--  <P>See Christian Zeller; <EM>Kalender-Formeln</EM>, Acta Mathematica, vol.
 
36
--  <STRONG>9</STRONG>, pp. 131-136; Nov. 1886. (Yes, that's <EM>not</EM>
 
37
--  a typo, it really appeared in eighteen-eightysix. In fact, that paper
 
38
--  is an expanded version of an earlier one from 1883!)
 
39
--  <P>See also
 
40
--  <A HREF="http://www.merlyn.demon.co.uk/zeller-c.htm">J.R. Stockton's page
 
41
--  on Zeller's congruence</A>.</DL>
 
42
--
 
43
--  <HISTORY>
 
44
--    29-JUL-2002   TW  Initial version.
 
45
--    28-OCT-2002   TW  Added 'Split'.
 
46
--  </HISTORY>
 
47
-------------------------------------------------------------------------------
 
48
 
 
49
pragma License (Modified_GPL);
 
50
 
 
51
with Ada.Calendar;
 
52
 
 
53
package Util.Calendar is
 
54
 
 
55
   pragma Elaborate_Body;
 
56
   --  Can't be pure, because Ada.Calendar isn't pure.
 
57
 
 
58
   type Weekday is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
 
59
 
 
60
   function Day_Of_Week
 
61
     (Year  : in Ada.Calendar.Year_Number;
 
62
      Month : in Ada.Calendar.Month_Number;
 
63
      Day   : in Ada.Calendar.Day_Number)
 
64
     return Weekday;
 
65
 
 
66
   function Day_Of_Week
 
67
     (Date : in Ada.Calendar.Time)
 
68
     return Weekday;
 
69
   --  Returns the day of the week. Works for all Gregorian dates. Provided
 
70
   --  here because it makes available this functionality for standard
 
71
   --  Ada.Calendar times without dragging in all the extended calendar
 
72
   --  support.
 
73
 
 
74
   type Hours_Type   is new Natural range 0 .. 23;
 
75
   type Minutes_Type is new Natural range 0 .. 59;
 
76
   type Seconds_Type is new Natural range 0 .. 59;
 
77
 
 
78
   procedure Split
 
79
     (Secs : in     Ada.Calendar.Day_Duration;
 
80
      Hrs  :    out Hours_Type;
 
81
      Min  :    out Minutes_Type;
 
82
      Sec  :    out Seconds_Type;
 
83
      Frac :    out Ada.Calendar.Day_Duration);
 
84
   --  Split a number of seconds @Secs@ into hours, minutes, seconds, and a
 
85
   --  sub-second fraction.
 
86
 
 
87
end Util.Calendar;