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 --
10 -- Copyright (C) 1999-2001 Ada Core Technologies, Inc. --
12 -- This specification is derived from the Ada Reference Manual for use with --
13 -- GNAT. The copyright notice above, and the license provisions that follow --
14 -- apply solely to the contents of the part following the private keyword. --
16 -- GNAT is free software; you can redistribute it and/or modify it under --
17 -- terms of the GNU General Public License as published by the Free Soft- --
18 -- ware Foundation; either version 2, or (at your option) any later ver- --
19 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
20 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
21 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
22 -- for more details. You should have received a copy of the GNU General --
23 -- Public License distributed with GNAT; see file COPYING. If not, write --
24 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
25 -- MA 02111-1307, USA. --
27 -- As a special exception, if other files instantiate generics from this --
28 -- unit, or you link this unit with other files to produce an executable, --
29 -- this unit does not by itself cause the resulting executable to be --
30 -- covered by the GNU General Public License. This exception does not --
31 -- however invalidate any other reasons why the executable file might be --
32 -- covered by the GNU Public License. --
34 -- GNAT was originally developed by the GNAT team at New York University. --
35 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
37 ------------------------------------------------------------------------------
39 -- This package augments standard Ada.Text_IO with facilities for input
40 -- and output of time values in standardized format.
42 package GNAT
.Calendar
.Time_IO
is
44 Picture_Error
: exception;
46 type Picture_String
is new String;
48 -- This is a string to describe date and time output format. The string is
49 -- a set of standard character and special tag that are replaced by the
50 -- corresponding values. It follows the GNU Date specification. Here are
51 -- the recognized directives :
64 -- %p locale's AM or PM
65 -- %r time, 12-hour (hh:mm:ss [AP]M)
66 -- %s seconds since 1970-01-01 00:00:00 UTC
67 -- (a nonstandard extension)
69 -- %T time, 24-hour (hh:mm:ss)
73 -- %a locale's abbreviated weekday name (Sun..Sat)
74 -- %A locale's full weekday name, variable length
76 -- %b locale's abbreviated month name (Jan..Dec)
77 -- %B locale's full month name, variable length
78 -- (January..December)
79 -- %c locale's date and time (Sat Nov 04 12:02:33 EST 1989)
80 -- %d day of month (01..31)
83 -- %j day of year (001..366)
85 -- %U week number of year with Sunday as first day of week
87 -- %w day of week (0..6) with 0 corresponding to Sunday
88 -- %W week number of year with Monday as first day of week
90 -- %x locale's date representation (mm/dd/yy)
91 -- %y last two digits of year (00..99)
94 -- By default, date pads numeric fields with zeroes. GNU date
95 -- recognizes the following nonstandard numeric modifiers:
97 -- - (hyphen) do not pad the field
98 -- _ (underscore) pad the field with spaces
100 ISO_Date
: constant Picture_String
;
101 -- This format follow the ISO 8601 standard. The format is "YYYY-MM-DD",
102 -- four digits year, month and day number separated by minus.
104 US_Date
: constant Picture_String
;
105 -- This format is the common US date format: "MM/DD/YY",
106 -- month and day number, two digits year separated by slashes.
108 European_Date
: constant Picture_String
;
109 -- This format is the common European date format: "DD/MM/YY",
110 -- day and month number, two digits year separated by slashes.
113 (Date
: Ada
.Calendar
.Time
;
114 Picture
: Picture_String
)
116 -- Return Date as a string with format Picture.
117 -- raise Picture_Error if picture string is wrong
120 (Date
: Ada
.Calendar
.Time
;
121 Picture
: Picture_String
);
122 -- Put Date with format Picture.
123 -- raise Picture_Error if picture string is wrong
126 ISO_Date
: constant Picture_String
:= "%Y-%m-%d";
127 US_Date
: constant Picture_String
:= "%m/%d/%y";
128 European_Date
: constant Picture_String
:= "%d/%m/%y";
130 end GNAT
.Calendar
.Time_IO
;