home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-os2-bin-20010916.zip / emx / gnatlib / a-calend.ads < prev    next >
Text File  |  2000-07-19  |  6KB  |  120 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUN-TIME COMPONENTS                         --
  4. --                                                                          --
  5. --                         A D A . C A L E N D A R                          --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.11 $                              --
  10. --                                                                          --
  11. --          Copyright (C) 1992-1997 Free Software Foundation, Inc.          --
  12. --                                                                          --
  13. -- This specification is derived from the Ada Reference Manual for use with --
  14. -- GNAT. The copyright notice above, and the license provisions that follow --
  15. -- apply solely to the  contents of the part following the private keyword. --
  16. --                                                                          --
  17. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  18. -- terms of the  GNU General Public License as published  by the Free Soft- --
  19. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  20. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  21. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  22. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  23. -- for  more details.  You should have  received  a copy of the GNU General --
  24. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  25. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  26. -- MA 02111-1307, USA.                                                      --
  27. --                                                                          --
  28. -- As a special exception,  if other files  instantiate  generics from this --
  29. -- unit, or you link  this unit with other files  to produce an executable, --
  30. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  31. -- covered  by the  GNU  General  Public  License.  This exception does not --
  32. -- however invalidate  any other reasons why  the executable file  might be --
  33. -- covered by the  GNU Public License.                                      --
  34. --                                                                          --
  35. -- GNAT was originally developed  by the GNAT team at  New York University. --
  36. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  37. --                                                                          --
  38. ------------------------------------------------------------------------------
  39.  
  40. package Ada.Calendar is
  41.  
  42.    type Time is private;
  43.  
  44.    --  Declarations representing limits of allowed local time values. Note that
  45.    --  these do NOT constrain the possible stored values of time which may well
  46.    --  permit a larger range of times (this is explicitly allowed in Ada 95).
  47.  
  48.    subtype Year_Number  is Integer range 1901 .. 2099;
  49.    subtype Month_Number is Integer range 1 .. 12;
  50.    subtype Day_Number   is Integer range 1 .. 31;
  51.  
  52.    subtype Day_Duration is Duration range 0.0 .. 86_400.0;
  53.  
  54.    function Clock return Time;
  55.  
  56.    function Year    (Date : Time) return Year_Number;
  57.    function Month   (Date : Time) return Month_Number;
  58.    function Day     (Date : Time) return Day_Number;
  59.    function Seconds (Date : Time) return Day_Duration;
  60.  
  61.    procedure Split
  62.      (Date    : Time;
  63.       Year    : out Year_Number;
  64.       Month   : out Month_Number;
  65.       Day     : out Day_Number;
  66.       Seconds : out Day_Duration);
  67.  
  68.    function Time_Of
  69.      (Year    : Year_Number;
  70.       Month   : Month_Number;
  71.       Day     : Day_Number;
  72.       Seconds : Day_Duration := 0.0)
  73.       return    Time;
  74.  
  75.    function "+" (Left : Time;     Right : Duration) return Time;
  76.    function "+" (Left : Duration; Right : Time)     return Time;
  77.    function "-" (Left : Time;     Right : Duration) return Time;
  78.    function "-" (Left : Time;     Right : Time)     return Duration;
  79.  
  80.    function "<"  (Left, Right : Time) return Boolean;
  81.    function "<=" (Left, Right : Time) return Boolean;
  82.    function ">"  (Left, Right : Time) return Boolean;
  83.    function ">=" (Left, Right : Time) return Boolean;
  84.  
  85.    Time_Error : exception;
  86.  
  87. private
  88.    pragma Inline (Clock);
  89.  
  90.    pragma Inline (Year);
  91.    pragma Inline (Month);
  92.    pragma Inline (Day);
  93.  
  94.    pragma Inline ("+");
  95.    pragma Inline ("-");
  96.  
  97.    pragma Inline ("<");
  98.    pragma Inline ("<=");
  99.    pragma Inline (">");
  100.    pragma Inline (">=");
  101.  
  102.    --  Time is represented as a signed duration from the base point which is
  103.    --  what Unix calls the EPOCH (i.e. 12 midnight (24:00:00), Dec 31st, 1969,
  104.    --  or if you prefer 0:00:00 on Jan 1st, 1970). Since Ada allows dates
  105.    --  before this EPOCH value, the stored duration value may be negative.
  106.  
  107.    --  The time value stored is typically a GMT value, as provided in standard
  108.    --  Unix environments. If this is the case then Split and Time_Of perform
  109.    --  required conversions to and from local times. The range of times that
  110.    --  can be stored in Time values depends on the declaration of the type
  111.    --  Duration, which must at least cover the required Ada range represented
  112.    --  by the declaration of Year_Number, but may be larger (we take full
  113.    --  advantage of the new permission in Ada 95 to store time values outside
  114.    --  the range that would be acceptable to Split). The Duration type is a
  115.    --  real value representing a time interval in seconds.
  116.  
  117.    type Time is new Duration;
  118.  
  119. end Ada.Calendar;
  120.