OSDN Git Service

2010-01-27 Vincent Celier <celier@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / g-catiio.ads
index 59f0520..1f73c21 100644 (file)
@@ -6,13 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---                            $Revision: 1.5 $
---                                                                          --
---            Copyright (C) 1999-2001 Ada Core Technologies, Inc.           --
---                                                                          --
--- This specification is derived from the Ada Reference Manual for use with --
--- GNAT. The copyright notice above, and the license provisions that follow --
--- apply solely to the  contents of the part following the private keyword. --
+--                     Copyright (C) 1999-2008, AdaCore                     --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -22,8 +16,8 @@
 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
 -- for  more details.  You should have  received  a copy of the GNU General --
 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.                                              --
 --                                                                          --
 -- As a special exception,  if other files  instantiate  generics from this --
 -- unit, or you link  this unit with other files  to produce an executable, --
@@ -33,7 +27,7 @@
 -- covered by the  GNU Public License.                                      --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
--- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
 --                                                                          --
 ------------------------------------------------------------------------------
 
@@ -43,9 +37,9 @@
 package GNAT.Calendar.Time_IO is
 
    Picture_Error : exception;
+   --  Exception raised for incorrect picture
 
    type Picture_String is new String;
-
    --  This is a string to describe date and time output format. The string is
    --  a set of standard character and special tag that are replaced by the
    --  corresponding values. It follows the GNU Date specification. Here are
@@ -97,12 +91,18 @@ package GNAT.Calendar.Time_IO is
    --
    --          -    (hyphen) do not pad the field
    --          _    (underscore) pad the field with spaces
+   --
+   --  Here are some GNAT extensions to the GNU Date specification:
+   --
+   --          %i   milliseconds (3 digits)
+   --          %e   microseconds (6 digits)
+   --          %o   nanoseconds  (9 digits)
 
-   ISO_Date      : constant Picture_String;
+   ISO_Date : constant Picture_String;
    --  This format follow the ISO 8601 standard. The format is "YYYY-MM-DD",
    --  four digits year, month and day number separated by minus.
 
-   US_Date       : constant Picture_String;
+   US_Date : constant Picture_String;
    --  This format is the common US date format: "MM/DD/YY",
    --  month and day number, two digits year separated by slashes.
 
@@ -112,16 +112,41 @@ package GNAT.Calendar.Time_IO is
 
    function Image
      (Date    : Ada.Calendar.Time;
-      Picture : Picture_String)
-      return    String;
-   --  Return Date as a string with format Picture.
-   --  raise Picture_Error if picture string is wrong
+      Picture : Picture_String) return String;
+   --  Return Date as a string with format Picture. Raise Picture_Error if
+   --  picture string is null or has an incorrect format.
 
-   procedure Put_Time
-     (Date    : Ada.Calendar.Time;
-      Picture : Picture_String);
-   --  Put Date with format Picture.
-   --  raise Picture_Error if picture string is wrong
+   function Value (Date : String) return Ada.Calendar.Time;
+   --  Parse the string Date and return its equivalent as a Time value. The
+   --  following time format is supported:
+   --
+   --     hh:mm:ss             - Date is the current date
+   --
+   --  The following formats are also supported. They all accept an optional
+   --  time with the format "hh:mm:ss". The time is separated from the date by
+   --  exactly one space character.
+   --
+   --  When the time is not specified, it is set to 00:00:00. The delimiter '*'
+   --  must be either '-' and '/' and both occurrences must use the same
+   --  character.
+   --
+   --  Trailing characters (in particular spaces) are not allowed
+   --
+   --     yyyy*mm*dd           - ISO format
+   --     yy*mm*dd             - Year is assumed to be 20yy
+   --     mm*dd*yyyy           - (US date format)
+   --     dd*mmm*yyyy          - month spelled out
+   --     yyyy*mmm*dd          - month spelled out
+   --     yyyymmdd             - Iso format, no separator
+   --     mmm dd, yyyy         - month spelled out
+   --     dd mmm yyyy          - month spelled out
+   --
+   --  Constraint_Error is raised if the input string is malformed (does not
+   --  conform to one of the above dates, or has an invalid time string), or
+   --  the resulting time is not valid.
+
+   procedure Put_Time (Date : Ada.Calendar.Time; Picture : Picture_String);
+   --  Put Date with format Picture. Raise Picture_Error if bad picture string
 
 private
    ISO_Date      : constant Picture_String := "%Y-%m-%d";