On Sep 2, 2008, at 12:38 PM, Andrew Ross wrote:
> On Tue, Sep 02, 2008 at 02:03:25AM -0700, Jerry wrote:
>>
>> On Sep 1, 2008, at 4:10 PM, Alan W. Irwin wrote:
>>
>>> On 2008-09-01 14:58-0700 Jerry wrote:
>>>
>>>> Andrew,
>>>>
>>>> Does the Ada example, with xmin hardcoded to 1_133_395_200.0,
>>>> generate the same Postscript as the C example?
>>>
>>> The current Ada example 29 code has
>>>
>>> xmin := 1133395200.0;
>>>
>>> (no underscores),
>>
>> Sorry--Ada ignores underscores in numeric constants.
>>
>>> and yes, that hard-coded value gives identical results to
>>> the C example which is implemented in UTC to avoid anomalies in
>>> daylight
>>> savings time that occur for such locales as the UK.
>>
>> From this and the proceeding discussion, I gather that the Ada
>> example with the Time_Of function, when run in the UK, does not
>> generate the same Postscript code as example 29 in C, but when run in
>> North America, it does. Is that correct?
>>
>> Again, could someone check to see if
>>
>> xmin := Long_Float(Time_Of(2005, 12, 1, 0.0) - Time_Of(1970, 1, 1,
>> 0.0));
>>
>> results in a value for xmin of 1_133_395_200.0 when run in the UK, as
>> it does in North America? According to my reading of the Ada
>> Reference Manual, it should.
>
> Jerry,
>
> Coming back to your original question. In the UK I get
> 1.13339880000000E+09 for the result of the above calculation.
>
> If I do export TZ="UTC" before running the example then I get the
> correct answer of 1.13339520000000E+09. Looks like gnat Time_Of is
> just calling the C library mktime function so is in local time
> (including any daylight savings).
>
> Andrew
>
Andrew, thanks for doing that check.
I've done a little more work looking into the Ada Reference Manual
and the actual code that implements things. A couple of things are
pretty glaring at this point, but I'm not sure what the actual
ramifications are without doing a lot more studying.
Ada 2005 has augmented the Calendar functionality substantially
relative to Ada 95 and for example has expanded time zone capability
and a table of leap seconds. Also, it appears that the default time
zone can be different depending on whether Ada 95 or Ada 05 is being
used or whether a particular flag is set or whether an optional
argument is used with a non-default value. To facilitate this, there
is an enhanced (and overloaded) version of the Time_Of function.
The Ada implementation appears to be in all Ada (no C or system
calls) and could potentially be useful, at least as a reference, to
the parallel discussion on this list about implementing a standalone
capability in PLplot.
I don't want to beat this to death (especially in light of the
parallel discussion to add a time facility to PLplot) but I'm curious
to know if the following change in Ada example 29 would have any
effect on your machine:
To the with- and use-clauses, add the lines Ada.Calendar.Formatting
and Ada.Calendar.Time_Zones so that they look like this:
with
Ada.Text_IO,
Ada.Numerics,
Ada.Numerics.Long_Elementary_Functions,
Ada.Calendar,
Ada.Calendar.Time_Zones,
Ada.Calendar.Formatting,
PLplot_Traditional,
PLplot_Auxiliary;
use
Ada.Numerics,
Ada.Numerics.Long_Elementary_Functions,
Ada.Calendar,
Ada.Calendar.Time_Zones,
Ada.Calendar.Formatting,
PLplot_Traditional,
PLplot_Auxiliary;
Then, add an argument Time_Zone => 0 to both of the Time_Of functions
so that the line looks like this:
xmin := Long_Float(Time_Of(2005, 12, 1, 0.0, Time_Zone => 0) -
Time_Of(1970, 1, 1, 0.0, Time_Zone => 0));
This should enforce a zero offset relative to UTC. On my machine,
there is no difference in the value of xmin.
If your compiler complains that it can't find Ada.Calendar.Formatting
and Ada.Calendar.Time_Zones or complains of "unmatched actual
"Time_Zone" in call," then your compiler is not Ada 2005 (probably <
4.3) and we'll consider the problem not worth pursuing any further.
Jerry
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel