From: gautier_niouzes@hotmail.com (Gautier)
Subject: Re: ADA.CALENDAR and midnight
Date: 6 Aug 2004 00:34:46 -0700
Date: 2004-08-06T00:34:46-07:00 [thread overview]
Message-ID: <17cd177c.0408052334.2ec44517@posting.google.com> (raw)
In-Reply-To: sa4smb1cgxp.fsf@snoopy.apana.org.au
Brian May :
> Going back to me to_string function, are there any packages (GPL
> compatible licence preferred) for displaying formatted output? For
> instance, my function would display "12:0:0", it would be preferred if
> I could display it as "12:00:00". I have a package called
> "Formatted_Output" by "Eugene Nonko, cm@liceum.secna.ru", but the
> license is unclear. I am not convinced the approach taken is ideal
> either. Ideally, I would prefer not to have to reinvent the wheel.
For obtaining all heading '0's you need there is a simple trick
(here, a Time_log function of mine, also 16-bit and Ada83 compatible):
with Calendar;
function Time_log return String is
use Calendar;
subtype Sec_int is Long_Integer; -- must contain 86_400
T : Time:= Clock;
m, s : Sec_int;
begin
s := Sec_int( Seconds(T) );
m := s / 60;
declare
-- + 100: trick for obtaining 0x
sY : constant String:= Integer'Image( Year(T));
sM : constant String:= Integer'Image( Month(T) + 100);
sD : constant String:= Integer'Image( Day(T) + 100);
shr: constant String:= Sec_int'Image( m / 60 + 100);
smn: constant String:= Sec_int'Image( m mod 60 + 100);
ssc: constant String:= Sec_int'Image( s mod 60 + 100);
begin
return
sY( sY'Last-3 .. sY'Last ) & '/' & -- not Year 10'000 compliant.
sM( sM'Last-1 .. sM'Last ) & '/' &
sD( sD'Last-1 .. sD'Last ) &
" " &
shr( shr'Last-1 .. shr'Last ) & ':' &
smn( smn'Last-1 .. smn'Last ) & ':' &
ssc( ssc'Last-1 .. ssc'Last );
end;
end Time_log;
HTH
________________________________________________________
Gautier -- http://www.mysunrise.ch/users/gdm/gsoft.htm
NB: For a direct answer, e-mail address on the Web site!
next prev parent reply other threads:[~2004-08-06 7:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-05 10:00 ADA.CALENDAR and midnight Brian May
2004-08-05 11:06 ` Frank Piron
2004-08-05 11:19 ` Nick Roberts
2004-08-05 11:46 ` Brian May
2004-08-05 12:01 ` Jano
2004-08-05 12:15 ` Jean-Pierre Rosen
2004-08-05 23:18 ` Brian May
2004-08-06 5:59 ` Martin Dowie
2004-08-06 7:34 ` Gautier [this message]
2004-08-05 13:01 ` Ada.Calendar " Jacob Sparre Andersen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox