Commit 7d304f61 by Emmanuel Briot Committed by Arnaud Charlet

g-calend.ads (No_Time): New constant, to represent an uninitialized time value

2007-12-06  Emmanuel Briot  <briot@adacore.com>

	* g-calend.ads (No_Time): New constant, to represent an uninitialized
	time value

	* g-catiio.ads, g-catiio.adb (Value): Added support for more date
	formats.
	(Month_Name_To_Number): New subprogram

	* g-dirope.adb (Get_Current_Dir): On windows, normalize the drive
	letter to upper-case.

From-SVN: r130839
parent 36fcf362
...@@ -56,6 +56,10 @@ package GNAT.Calendar is ...@@ -56,6 +56,10 @@ package GNAT.Calendar is
subtype Day_In_Year_Number is Positive range 1 .. 366; subtype Day_In_Year_Number is Positive range 1 .. 366;
subtype Week_In_Year_Number is Positive range 1 .. 53; subtype Week_In_Year_Number is Positive range 1 .. 53;
No_Time : constant Ada.Calendar.Time;
-- A constant set to the first date that can be represented by the type
-- Time. It can be used to indicate an uninitialized date.
function Hour (Date : Ada.Calendar.Time) return Hour_Number; function Hour (Date : Ada.Calendar.Time) return Hour_Number;
function Minute (Date : Ada.Calendar.Time) return Minute_Number; function Minute (Date : Ada.Calendar.Time) return Minute_Number;
function Second (Date : Ada.Calendar.Time) return Second_Number; function Second (Date : Ada.Calendar.Time) return Second_Number;
...@@ -131,4 +135,10 @@ private ...@@ -131,4 +135,10 @@ private
-- the Collected Algorithms of the ACM. The author of algorithm 199 is -- the Collected Algorithms of the ACM. The author of algorithm 199 is
-- Robert G. Tantzen. -- Robert G. Tantzen.
No_Time : constant Ada.Calendar.Time :=
Ada.Calendar.Time_Of
(Ada.Calendar.Year_Number'First,
Ada.Calendar.Month_Number'First,
Ada.Calendar.Day_Number'First);
end GNAT.Calendar; end GNAT.Calendar;
...@@ -118,15 +118,26 @@ package GNAT.Calendar.Time_IO is ...@@ -118,15 +118,26 @@ package GNAT.Calendar.Time_IO is
function Value (Date : String) return Ada.Calendar.Time; function Value (Date : String) return Ada.Calendar.Time;
-- Parse the string Date and return its equivalent as a Time value. The -- Parse the string Date and return its equivalent as a Time value. The
-- following formats are supported: -- following time format is supported:
-- --
-- yyyy*mm*dd hh:mm:ss - Delimiter '*' is either '-' or '/' -- hh:mm:ss - Date is the current date
-- yyyy*mm*dd - The time of day is set to 00:00:00
-- --
-- yy*mm*dd hh:mm:ss - Year is assumend to be 20YY -- The following formats are also supported. They all accept an optional
-- yy*mm*dd - The time of day is set to 00:00:00 -- 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.
-- --
-- hh:mm:ss - Date is the current date -- yyyy*mm*dd
-- 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 malformatted or -- Constraint_Error is raised if the input string is malformatted or
-- the resulting time is not valid. -- the resulting time is not valid.
......
...@@ -56,6 +56,10 @@ package body GNAT.Directory_Operations is ...@@ -56,6 +56,10 @@ package body GNAT.Directory_Operations is
procedure Free is new procedure Free is new
Ada.Unchecked_Deallocation (Dir_Type_Value, Dir_Type); Ada.Unchecked_Deallocation (Dir_Type_Value, Dir_Type);
On_Windows : constant Boolean := GNAT.OS_Lib.Directory_Separator = '\';
-- An indication that we are on Windows. Used in Get_Current_Dir, to
-- deal with drive letters in the beginning of absolute paths.
--------------- ---------------
-- Base_Name -- -- Base_Name --
--------------- ---------------
...@@ -591,6 +595,15 @@ package body GNAT.Directory_Operations is ...@@ -591,6 +595,15 @@ package body GNAT.Directory_Operations is
end if; end if;
Dir (Buffer'First .. Last) := Buffer (Buffer'First .. Last); Dir (Buffer'First .. Last) := Buffer (Buffer'First .. Last);
-- By default, the drive letter on Windows is in upper case
if On_Windows and then Last > Dir'First and then
Dir (Dir'First + 1) = ':'
then
Dir (Dir'First) :=
Ada.Characters.Handling.To_Upper (Dir (Dir'First));
end if;
end Get_Current_Dir; end Get_Current_Dir;
------------- -------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment