comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Getting current date and time
Date: Tue, 24 Jul 2007 08:24:58 -0700
Date: 2007-07-24T08:24:58-07:00	[thread overview]
Message-ID: <1185290698.850041.204530@z28g2000prd.googlegroups.com> (raw)
In-Reply-To: <1185267194.506294.197760@w3g2000hsg.googlegroups.com>

On Jul 24, 1:53 am, Maciej Sobczak <see.my.homep...@gmail.com> wrote:
> On 23 Lip, 23:43, Adam Beneschan <a...@irvine.com> wrote:
>
> > In Ada 2005, this is handled by the Differences procedure in
> > Ada.Calendar.Arithmetic (9.6.1).  You can use Ada.Calendar.Time_Of to
> > create the Time value for January 1, 1970, and then use that as a
> > parameter to Differences.
>
> The problem is that I need just a number of seconds (this is for
> interfacing with other software which uses that Unix-like time
> descriptions), so I cannot use the value which is broken down into
> several components.

Why not?  Differences returns the result in "days" and "seconds", and
you should be able to convert the "days" to seconds by multiplying it
by a value that I just recently helped my 9-year-old figure out, and
then adding the result to the second value, and then maybe adding the
leap seconds (see below).

> Moreover, the concept of leap seconds does not fit here neither (or
> does it?).

Your previous post said that the purpose was to "interfac[e] with
other software which uses that Unix-like time descriptions".  I don't
think we can answer anything else without knowing just what that other
software does.  If the other software uses seconds since January 1,
1970 (regardless of what OS you're on), then you should use the method
I described, and you should either use or not use the leap seconds
depending on whether the other software does or doesn't.  If the other
software uses the Unix time function on Unix but some other system
service on other OS's, you should probably just do whatever the other
software does.  This one really isn't an Ada problem.  We could
conceivably propose a new addition to Ada.Calendar.Arithmetic:

function
Return_Current_Time_However_The_Other_Software_Maciej_Is_Using_Does_It;

but I sort of doubt that a proposal like that would be accepted.

                          -- Adam






  parent reply	other threads:[~2007-07-24 15:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-22 21:21 Getting current date and time Maciej Sobczak
2007-07-22 23:00 ` Martin
2007-07-23 15:24   ` koburtch
2007-07-23 19:57   ` Maciej Sobczak
2007-07-23 20:02     ` Maciej Sobczak
2007-07-23 20:08       ` Maciej Sobczak
2007-07-23 21:43         ` Adam Beneschan
2007-07-24  8:53           ` Maciej Sobczak
2007-07-24  9:41             ` Georg Bauhaus
2007-07-24  9:58               ` Maciej Sobczak
2007-07-24 15:24             ` Adam Beneschan [this message]
2007-07-25  7:26               ` Maciej Sobczak
2007-07-25  7:42                 ` AW: " Grein, Christoph (Fa. ESG)
2007-07-28  8:20             ` Wilhelm Spickermann
2007-08-01  9:45         ` Jacob Sparre Andersen
2007-07-23 21:39       ` Adam Beneschan
2007-07-23 19:26 ` Gautier
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox