This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Time_IO.Value enhanced to parse ISO-8861 UTC date and time


The function Value of package GNAT.Calendar.Time_IO has been enhanced
to parse strings containing UTC date and time.

After this patch the following test works fine.

with Ada.Calendar;          use Ada.Calendar;
with Ada.Text_IO;           use Ada.Text_IO;
with GNAT.Calendar.Time_IO; use GNAT.Calendar.Time_IO;

procedure Do_Test is
   Picture : Picture_String := "%Y-%m-%dT%H:%M:%S,%i";
   T1      : Time;
   T2      : Time;
   T3      : Time;
   T4      : Time;
   T5      : Time;
begin
   T1 := Value ("2017-04-14T14:47:06");
   pragma Assert (Image (T1, Picture) = "2017-04-14T14:47:06,000");

   T2 := Value ("2017-04-14T14:47:06Z");
   pragma Assert (Image (T2, Picture) = "2017-04-14T14:47:06,000");

   T3 := Value ("2017-04-14T14:47:06,999");
   pragma Assert (Image (T3, Picture) = "2017-04-14T14:47:06,999");

   T4 := Value ("2017-04-14T19:47:06+05");
   pragma Assert (Image (T4, Picture) = "2017-04-14T14:47:06,000");

   T5 := Value ("2017-04-14T09:00:06-05:47");
   pragma Assert (Image (T5, Picture) = "2017-04-14T14:47:06,000");
end;

Command: gnatmake -gnata do_test.adb; ./do_test

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-09-06  Javier Miranda  <miranda@adacore.com>

	* g-catiio.ads, g-catiio.adb (Value): Extended to parse an UTC time
	following ISO-8861.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]