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-2005, AdaCore --
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, 51 Franklin Street, Fifth Floor, --
24 -- Boston, MA 02110-1301, 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;
44 -- Exception raised for incorrect picture
46 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 -- Here are some GNAT extensions to the GNU Date specification:
101 -- %i milliseconds (3 digits)
102 -- %e microseconds (6 digits)
103 -- %o nanoseconds (9 digits)
105 ISO_Date
: constant Picture_String
;
106 -- This format follow the ISO 8601 standard. The format is "YYYY-MM-DD",
107 -- four digits year, month and day number separated by minus.
109 US_Date
: constant Picture_String
;
110 -- This format is the common US date format: "MM/DD/YY",
111 -- month and day number, two digits year separated by slashes.
113 European_Date
: constant Picture_String
;
114 -- This format is the common European date format: "DD/MM/YY",
115 -- day and month number, two digits year separated by slashes.
118 (Date
: Ada
.Calendar
.Time
;
119 Picture
: Picture_String
) return String;
120 -- Return Date as a string with format Picture. Raise Picture_Error if
121 -- picture string is wrong.
124 (Date
: Ada
.Calendar
.Time
;
125 Picture
: Picture_String
);
126 -- Put Date with format Picture. Raise Picture_Error if picture string is
130 ISO_Date
: constant Picture_String
:= "%Y-%m-%d";
131 US_Date
: constant Picture_String
:= "%m/%d/%y";
132 European_Date
: constant Picture_String
:= "%d/%m/%y";
134 end GNAT
.Calendar
.Time_IO
;