1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- G N A T . C A L E N D A R . T I M E _ I O --
9 -- Copyright (C) 1999-2001 Ada Core Technologies, Inc. --
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. --
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. --
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. --
33 -- GNAT was originally developed by the GNAT team at New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc. --
36 ------------------------------------------------------------------------------
38 -- This package augments standard Ada.Text_IO with facilities for input
39 -- and output of time values in standardized format.
41 package GNAT
.Calendar
.Time_IO
is
43 Picture_Error
: exception;
45 type Picture_String
is new String;
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 :
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)
68 -- %T time, 24-hour (hh:mm:ss)
72 -- %a locale's abbreviated weekday name (Sun..Sat)
73 -- %A locale's full weekday name, variable length
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)
82 -- %j day of year (001..366)
84 -- %U week number of year with Sunday as first day of week
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
89 -- %x locale's date representation (mm/dd/yy)
90 -- %y last two digits of year (00..99)
93 -- By default, date pads numeric fields with zeroes. GNU date
94 -- recognizes the following nonstandard numeric modifiers:
96 -- - (hyphen) do not pad the field
97 -- _ (underscore) pad the field with spaces
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.
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.
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.
112 (Date
: Ada
.Calendar
.Time
;
113 Picture
: Picture_String
)
115 -- Return Date as a string with format Picture.
116 -- raise Picture_Error if picture string is wrong
119 (Date
: Ada
.Calendar
.Time
;
120 Picture
: Picture_String
);
121 -- Put Date with format Picture.
122 -- raise Picture_Error if picture string is wrong
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";
129 end GNAT
.Calendar
.Time_IO
;