* function Clock return Time; Time is a number, a string...?
@ 2007-11-06 22:32 j.khaldi
2007-11-06 23:21 ` anon
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: j.khaldi @ 2007-11-06 22:32 UTC (permalink / raw)
In "package Ada.Calendar"..
function Clock return Time; // what is the type of Time here?
A string? A number? Something else?
"Time" has been declarated "private", this means it is untyped yet;
In other words, if I had to call the the function Year with the
argument Date, how should I do:
Date := The_Date; // for example: 11 dicember 2004
GetYear := Year(Date);
Thanks!
Jilani
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: function Clock return Time; Time is a number, a string...?
2007-11-06 22:32 function Clock return Time; Time is a number, a string...? j.khaldi
@ 2007-11-06 23:21 ` anon
2007-11-07 0:15 ` Jeffrey Creem
2007-11-07 10:49 ` Georg Bauhaus
2 siblings, 0 replies; 5+ messages in thread
From: anon @ 2007-11-06 23:21 UTC (permalink / raw)
In Ada it is a private maybe numeric type or it could be something else
and in the Ada.Calendar package their are other routines that convert this
private type to other type that a program can use.
To use:
--
-- tt.adb
--
with Ada.Calendar ;
use Ada.Calendar ;
with Text_IO ;
use Text_IO ;
with Ada.Integer_Text_IO ;
use Ada.Integer_Text_IO ;
procedure tt is
Clock_Value : Time := Clock ;
begin
Put ( "Date => " ) ;
Put ( Year ( Clock_Value ), 4 ) ;
Put ( '/' ) ;
if Month ( Clock_Value ) < 10 then
Put ( '0' ) ;
end if ;
Put ( Month ( Clock_Value ), 1 ) ;
Put ( '/' ) ;
if Day ( Clock_Value ) < 10 then
Put ( '0' ) ;
end if ;
Put ( Day ( Clock_Value ), 1 ) ;
New_Line ;
end ;
In <1194388351.937058.41110@k79g2000hse.googlegroups.com>, j.khaldi@oltrelinux.com writes:
>In "package Ada.Calendar"..
>function Clock return Time; // what is the type of Time here?
>A string? A number? Something else?
>"Time" has been declarated "private", this means it is untyped yet;
>In other words, if I had to call the the function Year with the
>argument Date, how should I do:
>Date := The_Date; // for example: 11 dicember 2004
>GetYear := Year(Date);
>Thanks!
>
>Jilani
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: function Clock return Time; Time is a number, a string...?
2007-11-06 22:32 function Clock return Time; Time is a number, a string...? j.khaldi
2007-11-06 23:21 ` anon
@ 2007-11-07 0:15 ` Jeffrey Creem
2007-11-07 10:49 ` Georg Bauhaus
2 siblings, 0 replies; 5+ messages in thread
From: Jeffrey Creem @ 2007-11-07 0:15 UTC (permalink / raw)
j.khaldi@oltrelinux.com wrote:
> In "package Ada.Calendar"..
> function Clock return Time; // what is the type of Time here?
> A string? A number? Something else?
> "Time" has been declarated "private", this means it is untyped yet;
> In other words, if I had to call the the function Year with the
> argument Date, how should I do:
> Date := The_Date; // for example: 11 dicember 2004
> GetYear := Year(Date);
> Thanks!
>
> Jilani
>
It is private and you don't get to know and any code you write that
attempts to guess will almost certainly break. If you need to do what
you are asking you need to use the other subprograms in calendar to
build a time value based on non private items.
In your case
date := Ada.Calendar.Time_Of(year => 2004, Month => 12, Day => 11);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: function Clock return Time; Time is a number, a string...?
2007-11-06 22:32 function Clock return Time; Time is a number, a string...? j.khaldi
2007-11-06 23:21 ` anon
2007-11-07 0:15 ` Jeffrey Creem
@ 2007-11-07 10:49 ` Georg Bauhaus
2007-11-07 10:56 ` Georg Bauhaus
2 siblings, 1 reply; 5+ messages in thread
From: Georg Bauhaus @ 2007-11-07 10:49 UTC (permalink / raw)
On Tue, 2007-11-06 at 14:32 -0800, j.khaldi@oltrelinux.com wrote:
> In "package Ada.Calendar"..
> function Clock return Time; // what is the type of Time here?
> A string? A number? Something else?
No, because...
> "Time" has been declarated "private", this means it is untyped yet;
... this means Time is indeed fully typed, but privately--stay out of
its living room and use the public interface of the type Time
to deal with Time objects.
See Jeffrey Cream's post for an example, and
http://www.adaic.org/standards/05rm/html/RM-9-6.html
for more details.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-11-07 10:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-06 22:32 function Clock return Time; Time is a number, a string...? j.khaldi
2007-11-06 23:21 ` anon
2007-11-07 0:15 ` Jeffrey Creem
2007-11-07 10:49 ` Georg Bauhaus
2007-11-07 10:56 ` Georg Bauhaus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox