From: Jeffrey Carter <spam@spam.com>
Subject: Re: timeouts
Date: Sun, 22 Aug 2004 19:56:34 GMT
Date: 2004-08-22T19:56:34+00:00 [thread overview]
Message-ID: <ST6Wc.30536$9Y6.10706@newsread1.news.pas.earthlink.net> (raw)
In-Reply-To: <sa4pt5jre7c.fsf@snoopy.apana.org.au>
Brian May wrote:
> Nothing that I can see:
>
> function Strip(Value : in String) return String is
> I : Natural := Value'First;
> Continue : Boolean := True;
> begin
> while I <= Value'Last and Continue loop
> if Value(I) = ' ' then
> I := I + 1;
> else
> Continue := False;
> end if;
> end loop;
> return Value(I..Value'Last);
> end Strip;
Ada.Strings.Fixed.Trim?
> function To_String(The_Time : in Time) return String is
> Duration : Integer;
> H : Integer range 0..23;
> M : Integer range 0..60;
> S : Integer range 0..60;
> begin
> Duration := Integer(Seconds(The_Time));
>
> S := Duration mod 60;
> Duration := (Duration-S)/60;
>
> M := Duration mod 60;
> Duration := (Duration-M)/60;
>
> H := Duration mod 24;
>
> return Strip(Integer'Image(H))&":"
> &Strip(Integer'Image(M))&":"
> &Strip(Integer'Image(S));
This can give things like "7:16:3", which I consider ugly.
PragmARC.Images.Image lets you say
Image (H, Width => 2, Zero_Filled => True);
which can produce prettier time images.
PragmARC.Date_Handler uses this internal procedure to split the seconds
value from Ada.Calendar into hour, minute, and seconds:
procedure Split (Seconds : in out Calendar.Day_Duration;
Hour : out Hour_Number;
Minute : out Minute_Number)
is
Seconds_Per_Minute : constant := 60;
Minutes_Per_Hour : constant := 60;
Seconds_Per_Hour : constant := Minutes_Per_Hour *
Seconds_Per_Minute;
begin -- Split
if Seconds >= Calendar.Day_Duration'Last then
Seconds := 0.0;
Hour := 0;
Minute := 0;
return;
end if;
Hour := Integer'Max (Integer (Seconds / Seconds_Per_Hour - 0.5),
Hour_Number'First);
Seconds := Seconds - Calendar.Day_Duration (Hour) * Seconds_Per_Hour;
Minute := Integer'Max (Integer (Seconds / Seconds_Per_Minute - 0.5),
Minute_Number'First);
Seconds := Seconds - Calendar.Day_Duration (Minute) *
Seconds_Per_Minute;
end Split;
where
subtype Hour_Number is Integer range 0 .. 23;
subtype Minute_Number is Integer range 0 .. 59;
FWIW.
> end To_String;
--
Jeff Carter
"Now go away or I shall taunt you a second time."
Monty Python & the Holy Grail
07
next prev parent reply other threads:[~2004-08-22 19:56 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-18 23:46 timeouts Brian May
2004-08-19 1:03 ` timeouts Jeffrey Carter
2004-08-19 3:10 ` timeouts Brian May
2004-08-19 19:18 ` timeouts Jeffrey Carter
2004-08-22 4:25 ` timeouts Brian May
2004-08-22 11:00 ` timeouts Stephen Leake
2004-08-22 11:29 ` timeouts Brian May
2004-08-22 19:56 ` Jeffrey Carter [this message]
2004-08-27 10:22 ` timeouts Brian May
2004-08-27 10:31 ` Cygwin and gcc-ada 3.4.1 (was Re: timeouts) Jano
2004-09-13 15:05 ` Dr Steve Sangwine
2004-08-27 17:54 ` timeouts Jeffrey Carter
2004-08-28 0:24 ` timeouts Stephen Leake
2004-08-29 0:24 ` timeouts Brian May
2004-08-29 4:40 ` timeouts tmoran
2004-08-29 8:57 ` timeouts Brian May
2004-08-29 17:17 ` timeouts tmoran
2004-08-29 22:37 ` timeouts Brian May
2004-08-29 13:31 ` timeouts Stephen Leake
2004-08-29 22:32 ` timeouts Brian May
2004-08-30 1:06 ` timeouts Stephen Leake
2004-08-30 12:17 ` timeouts Jano
2004-08-19 3:40 ` timeouts Steve
2004-08-22 4:18 ` timeouts Brian May
2004-08-22 12:54 ` timeouts Jeff C,
2004-08-26 1:28 ` timeouts Brian May
2004-08-26 10:00 ` timeouts Pascal Obry
2004-08-26 11:34 ` timeouts Georg Bauhaus
2004-08-26 11:58 ` timeouts Jean-Marc Bourguet
2004-08-26 22:20 ` timeouts Brian May
2004-08-27 18:12 ` timeouts Pascal Obry
2004-08-26 12:30 ` timeouts Stephen Leake
2004-08-26 22:54 ` timeouts Brian May
2004-08-27 1:17 ` timeouts Stephen Leake
2004-08-27 1:31 ` timeouts tmoran
2004-08-27 8:03 ` timeouts Brian May
2004-08-26 13:34 ` timeouts Steve
2004-08-26 14:02 ` timeouts Georg Bauhaus
2004-08-26 23:03 ` SPARK Brian May
2004-08-27 10:11 ` SPARK Georg Bauhaus
2004-08-26 23:20 ` timeouts Brian May
2004-08-27 10:20 ` timeouts Georg Bauhaus
2004-08-26 12:38 ` timeouts Jano
2004-08-26 19:07 ` timeouts Randy Brukardt
2004-08-26 21:25 ` timeouts tmoran
2004-08-26 23:01 ` timeouts Brian May
2004-08-27 0:03 ` timeouts Björn Persson
2004-08-27 9:31 ` timeouts Jano
2004-08-26 22:59 ` timeouts Brian May
2004-08-27 9:58 ` timeouts Jano
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox