OSDN Git Service

* 1aexcept.adb, 1aexcept.ads, 1ic.ads, 1ssecsta.adb,
[pf3gnuchains/gcc-fork.git] / gcc / ada / g-catiio.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUN-TIME COMPONENTS                         --
4 --                                                                          --
5 --                G N A T . C A L E N D A R . T I M E _ I O                 --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --            Copyright (C) 1999-2001 Ada Core Technologies, Inc.           --
10 --                                                                          --
11 -- This specification is derived from the Ada Reference Manual for use with --
12 -- GNAT. The copyright notice above, and the license provisions that follow --
13 -- apply solely to the  contents of the part following the private keyword. --
14 --                                                                          --
15 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
16 -- terms of the  GNU General Public License as published  by the Free Soft- --
17 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
18 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
19 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
20 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
21 -- for  more details.  You should have  received  a copy of the GNU General --
22 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
23 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
24 -- MA 02111-1307, USA.                                                      --
25 --                                                                          --
26 -- As a special exception,  if other files  instantiate  generics from this --
27 -- unit, or you link  this unit with other files  to produce an executable, --
28 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
29 -- covered  by the  GNU  General  Public  License.  This exception does not --
30 -- however invalidate  any other reasons why  the executable file  might be --
31 -- covered by the  GNU Public License.                                      --
32 --                                                                          --
33 -- GNAT was originally developed  by the GNAT team at  New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
35 --                                                                          --
36 ------------------------------------------------------------------------------
37
38 --  This package augments standard Ada.Text_IO with facilities for input
39 --  and output of time values in standardized format.
40
41 package GNAT.Calendar.Time_IO is
42
43    Picture_Error : exception;
44
45    type Picture_String is new String;
46
47    --  This is a string to describe date and time output format. The string is
48    --  a set of standard character and special tag that are replaced by the
49    --  corresponding values. It follows the GNU Date specification. Here are
50    --  the recognized directives :
51    --
52    --          %    a literal %
53    --          n    a newline
54    --          t    a horizontal tab
55    --
56    --          Time fields:
57    --
58    --          %H   hour (00..23)
59    --          %I   hour (01..12)
60    --          %k   hour ( 0..23)
61    --          %l   hour ( 1..12)
62    --          %M   minute (00..59)
63    --          %p   locale's AM or PM
64    --          %r   time, 12-hour (hh:mm:ss [AP]M)
65    --          %s   seconds  since 1970-01-01  00:00:00 UTC
66    --                (a nonstandard extension)
67    --          %S   second (00..59)
68    --          %T   time, 24-hour (hh:mm:ss)
69    --
70    --          Date fields:
71    --
72    --          %a   locale's abbreviated weekday name (Sun..Sat)
73    --          %A   locale's    full   weekday   name,    variable   length
74    --                  (Sunday..Saturday)
75    --          %b   locale's abbreviated month name (Jan..Dec)
76    --          %B   locale's    full    month    name,   variable    length
77    --                  (January..December)
78    --          %c   locale's date and time (Sat Nov 04 12:02:33 EST 1989)
79    --          %d   day of month (01..31)
80    --          %D   date (mm/dd/yy)
81    --          %h   same as %b
82    --          %j   day of year (001..366)
83    --          %m   month (01..12)
84    --          %U   week number  of year with  Sunday as first day  of week
85    --                  (00..53)
86    --          %w   day of week (0..6) with 0 corresponding to Sunday
87    --          %W   week number  of year with  Monday as first day  of week
88    --                  (00..53)
89    --          %x   locale's date representation (mm/dd/yy)
90    --          %y   last two digits of year (00..99)
91    --          %Y   year (1970...)
92    --
93    --          By default,  date pads numeric fields with zeroes.  GNU date
94    --          recognizes the following nonstandard numeric modifiers:
95    --
96    --          -    (hyphen) do not pad the field
97    --          _    (underscore) pad the field with spaces
98
99    ISO_Date      : constant Picture_String;
100    --  This format follow the ISO 8601 standard. The format is "YYYY-MM-DD",
101    --  four digits year, month and day number separated by minus.
102
103    US_Date       : constant Picture_String;
104    --  This format is the common US date format: "MM/DD/YY",
105    --  month and day number, two digits year separated by slashes.
106
107    European_Date : constant Picture_String;
108    --  This format is the common European date format: "DD/MM/YY",
109    --  day and month number, two digits year separated by slashes.
110
111    function Image
112      (Date    : Ada.Calendar.Time;
113       Picture : Picture_String)
114       return    String;
115    --  Return Date as a string with format Picture.
116    --  raise Picture_Error if picture string is wrong
117
118    procedure Put_Time
119      (Date    : Ada.Calendar.Time;
120       Picture : Picture_String);
121    --  Put Date with format Picture.
122    --  raise Picture_Error if picture string is wrong
123
124 private
125    ISO_Date      : constant Picture_String := "%Y-%m-%d";
126    US_Date       : constant Picture_String := "%m/%d/%y";
127    European_Date : constant Picture_String := "%d/%m/%y";
128
129 end GNAT.Calendar.Time_IO;