comp.lang.ada
 help / color / mirror / Atom feed
* Timetype
@ 2002-06-27 20:31 Björn Lundin
  2002-06-27 21:03 ` Timetype David C. Hoos
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Björn Lundin @ 2002-06-27 20:31 UTC (permalink / raw)



Hello1
Can anyone explain this to me?

cut from a-calend.ads
--  Declarations representing limits of allowed local time values. Note that
--  these do NOT constrain the possible stored values of time which may well
--  permit a larger range of times (this is explicitly allowed in Ada 95).

   subtype Year_Number  is Integer range 1901 .. 2099;


Does it mean that i can write an application dealing with historical dates 
using the time_type?

It seems to me that a date like 05-Jun-1712 would cause
constraint_error.

Does anyone know the reason for this small range of years in
the timetype?

/Bj�rn



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Timetype
  2002-06-27 20:31 Timetype Björn Lundin
@ 2002-06-27 21:03 ` David C. Hoos
  2002-06-28  5:26 ` Timetype Mark Biggar
  2002-06-28 12:53 ` Timetype Jacob Sparre Andersen
  2 siblings, 0 replies; 7+ messages in thread
From: David C. Hoos @ 2002-06-27 21:03 UTC (permalink / raw)



----- Original Message -----
From: "Bj�rn Lundin" <bjorn.lundin@swipnet.se>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Thursday, June 27, 2002 3:31 PM
Subject: Timetype


>
> Hello1
> Can anyone explain this to me?
>
> cut from a-calend.ads
> --  Declarations representing limits of allowed local time values. Note
that
> --  these do NOT constrain the possible stored values of time which may
well
> --  permit a larger range of times (this is explicitly allowed in Ada 95).
>
>    subtype Year_Number  is Integer range 1901 .. 2099;
>
>
> Does it mean that i can write an application dealing with historical dates
> using the time_type?
>
Not exactly.  The problem would be with the Split and Time_Of subprograms,
not with the representation of values of type Time.

> It seems to me that a date like 05-Jun-1712 would cause
> constraint_error.
That's correct, as far as the use of the aforementioned subprograms is
concerned.
>
> Does anyone know the reason for this small range of years in
> the timetype?

The Year_Number range of 1901 .. 2099 was deliberately chosen so that
implementations
could use the simple rule that if (Year mod 4) = 0 then the year is a leap
year.

I.e., it does not have to deal with the more complex rule that
is_Leap_Year := (Year mod 4) = 0 and then
((Year mod 100) /= 0 or else (Year mod 400) = 0);
to say nothing about the dates on which various countries switched from the
Julian to the
Gegorian calendar.

There is also the complication that on UNIX systems, the range of time
representable in
a 32-bit integer extends only from December 13, 1901 through January 18,
2038.

>
> /Bj�rn
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
>




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Timetype
  2002-06-27 20:31 Timetype Björn Lundin
  2002-06-27 21:03 ` Timetype David C. Hoos
@ 2002-06-28  5:26 ` Mark Biggar
  2002-06-28 13:47   ` Timetype Marin David Condic
                     ` (2 more replies)
  2002-06-28 12:53 ` Timetype Jacob Sparre Andersen
  2 siblings, 3 replies; 7+ messages in thread
From: Mark Biggar @ 2002-06-28  5:26 UTC (permalink / raw)


Bj�rn Lundin wrote:
> 
> Hello1
> Can anyone explain this to me?
> 
> cut from a-calend.ads
> --  Declarations representing limits of allowed local time values. Note that
> --  these do NOT constrain the possible stored values of time which may well
> --  permit a larger range of times (this is explicitly allowed in Ada 95).
> 
>    subtype Year_Number  is Integer range 1901 .. 2099;
> 
> Does it mean that i can write an application dealing with historical dates
> using the time_type?
> 
> It seems to me that a date like 05-Jun-1712 would cause
> constraint_error.
> 
> Does anyone know the reason for this small range of years in
> the timetype?

Yes, this range allows using the expression (year mod 4 = 0) to test
test for leap years. BTW taking your example date, which one do you
mean?  There is a 11 day difference between 05-jun-1712 in England and 
its colonies and that date in most of Europe.  England didn't convert
to the Gregorian calendar until 1752, while most of Catholic europe
converted in the 1500's.  Russia didn't convert until the 1920's, so
even Ada's year range can cause problems with historical dates. The
standard writers didn't want to deal with the mess that the calendar 
is in.

--
Mark Biggar
mark.a.biggar@attbi.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Timetype
  2002-06-27 20:31 Timetype Björn Lundin
  2002-06-27 21:03 ` Timetype David C. Hoos
  2002-06-28  5:26 ` Timetype Mark Biggar
@ 2002-06-28 12:53 ` Jacob Sparre Andersen
  2 siblings, 0 replies; 7+ messages in thread
From: Jacob Sparre Andersen @ 2002-06-28 12:53 UTC (permalink / raw)


Bj�rn Lundin wrote:

>    subtype Year_Number  is Integer range 1901 .. 2099;
> 
> Does it mean that i can write an application dealing with historical dates
> using the time_type?

You should not (as others already have written) expect to be
able to use the type Ada.Calendar.Time for dates outside the
range 1901 to 2099.

> It seems to me that a date like 05-Jun-1712 would cause
> constraint_error.

Yes, but nothing prevents you from implementing your own
date or time type, which extends this range. There are
actually already at least one such package, which I found
through "comp.lang.ada". Using a calendar extending
sufficiently far back in time, you will also have to be
careful about switches in the calendar systems which are
different in different locations/countries.

Jacob
-- 
"ikke engang statens embedsm�nd form�r at s�tte sig
 tilstr�kkeligt ind i, om de ting de st�tter udvikling af,
 rent faktisk er udviklet og patenterede f�r!" -- Erik Lange



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Timetype
  2002-06-28  5:26 ` Timetype Mark Biggar
@ 2002-06-28 13:47   ` Marin David Condic
  2002-06-28 17:12   ` Timetype Björn Lundin
  2002-06-28 23:51   ` Timetype Robert C. Leif
  2 siblings, 0 replies; 7+ messages in thread
From: Marin David Condic @ 2002-06-28 13:47 UTC (permalink / raw)


An important observation is that the Ada Time was designed for dealing with
the most common time computation problems and didn't want to impose
unnecessary overhead, confusion & implementation difficulty. For someone who
needs to deal with a wider range to cover historical dates, the correct
answer is "Devise your own Calendar package that implements the policies you
want for years outside the normal range."

This sort of thing is also done where you might have special hardware clocks
with accuracy issues, etc. (Sometimes you have more than one time source -
which one is Ada.Calendar going to use?) It would make sense to model one's
home-grown Calendar package on Ada.Calendar to whatever extent is possible.
There are always going to be times when you need something substantially
different from whatever the language (any language) can provide you.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com


"Mark Biggar" <mark.a.biggar@attbi.com> wrote in message
news:3D1BF397.CC974E8E@attbi.com...
>
> Yes, this range allows using the expression (year mod 4 = 0) to test
> test for leap years. BTW taking your example date, which one do you
> mean?  There is a 11 day difference between 05-jun-1712 in England and
> its colonies and that date in most of Europe.  England didn't convert
> to the Gregorian calendar until 1752, while most of Catholic europe
> converted in the 1500's.  Russia didn't convert until the 1920's, so
> even Ada's year range can cause problems with historical dates. The
> standard writers didn't want to deal with the mess that the calendar
> is in.
>






^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Timetype
  2002-06-28  5:26 ` Timetype Mark Biggar
  2002-06-28 13:47   ` Timetype Marin David Condic
@ 2002-06-28 17:12   ` Björn Lundin
  2002-06-28 23:51   ` Timetype Robert C. Leif
  2 siblings, 0 replies; 7+ messages in thread
From: Björn Lundin @ 2002-06-28 17:12 UTC (permalink / raw)


Mark Biggar wrote:


> Yes, this range allows using the expression (year mod 4 = 0) to test
> test for leap years. 

makes sense
 
> BTW taking your example date, which one do you
> mean?  There is a 11 day difference between 05-jun-1712 in England and
> its colonies and that date in most of Europe.  England didn't convert
> to the Gregorian calendar until 1752, while most of Catholic europe
> converted in the 1500's.  Russia didn't convert until the 1920's, so
> even Ada's year range can cause problems with historical dates. The
> standard writers didn't want to deal with the mess that the calendar
> is in.
> 

Hmm, thats a bit like you can't ask anyone for what time it is,
unless you are sure that there's no timezone in between...

One way of dealing with that would be to say the date is in the eye of 
the writer, so if a russin wrote 'October revolution', a swede would know
it took place in November.

/Bj�rn



^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Timetype
  2002-06-28  5:26 ` Timetype Mark Biggar
  2002-06-28 13:47   ` Timetype Marin David Condic
  2002-06-28 17:12   ` Timetype Björn Lundin
@ 2002-06-28 23:51   ` Robert C. Leif
  2 siblings, 0 replies; 7+ messages in thread
From: Robert C. Leif @ 2002-06-28 23:51 UTC (permalink / raw)


From: Bob Leif
To: Mark Biggar et al.
XML data types includes the Gregorian Calendar. A package
XML_IO.Calendar might be a solution. 
XML Schema Part 2: Datatypes
W3C Recommendation 02 May 2001
http://www.w3.org/TR/xmlschema-2/

3.2 Primitive datatypes
3.2.1 string 
3.2.2 boolean 
3.2.3 decimal 
3.2.4 float 
3.2.5 double 
3.2.6 duration 
3.2.7 dateTime 
3.2.8 time 
3.2.9 date 
3.2.10 gYearMonth 
3.2.11 gYear 
3.2.12 gMonthDay 
3.2.13 gDay 
3.2.14 gMonth 
3.2.15 hexBinary 
3.2.16 base64Binary 
3.2.17 anyURI 
3.2.18 QName 
3.2.19 NOTATION

The Sun DEVELOPER CONNECTION page shows
Sun[tm] XML Datatypes Library in JAVA 
Product Version: Preview Version 2.1
Release Date: April, 2002
System Requirements: JDK 1.3
Developer Name: Kohsuke Kawaguchi
File Name: xsdlib.20020414.zip   Size: 529K
http://wwws.sun.com/software/xml/developers/xsdlib2/

I have not looked at this because I have no interest in JAVA. However. I
am curious on how the XML enumerated types were mapped to JAVA.



-----Original Message-----
From: comp.lang.ada-admin@ada.eu.org
[mailto:comp.lang.ada-admin@ada.eu.org] On Behalf Of Mark Biggar
Sent: Thursday, June 27, 2002 10:26 PM
To: comp.lang.ada@ada.eu.org
Subject: Re: Timetype

Björn Lundin wrote:
> 
> Hello1
> Can anyone explain this to me?
> 
> cut from a-calend.ads
> --  Declarations representing limits of allowed local time values.
Note that
> --  these do NOT constrain the possible stored values of time which
may well
> --  permit a larger range of times (this is explicitly allowed in Ada
95).
> 
>    subtype Year_Number  is Integer range 1901 .. 2099;
> 
> Does it mean that i can write an application dealing with historical
dates
> using the time_type?
> 
> It seems to me that a date like 05-Jun-1712 would cause
> constraint_error.
> 
> Does anyone know the reason for this small range of years in
> the timetype?

Yes, this range allows using the expression (year mod 4 = 0) to test
test for leap years. BTW taking your example date, which one do you
mean?  There is a 11 day difference between 05-jun-1712 in England and 
its colonies and that date in most of Europe.  England didn't convert
to the Gregorian calendar until 1752, while most of Catholic europe
converted in the 1500's.  Russia didn't convert until the 1920's, so
even Ada's year range can cause problems with historical dates. The
standard writers didn't want to deal with the mess that the calendar 
is in.

--
Mark Biggar
mark.a.biggar@attbi.com




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-06-28 23:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-27 20:31 Timetype Björn Lundin
2002-06-27 21:03 ` Timetype David C. Hoos
2002-06-28  5:26 ` Timetype Mark Biggar
2002-06-28 13:47   ` Timetype Marin David Condic
2002-06-28 17:12   ` Timetype Björn Lundin
2002-06-28 23:51   ` Timetype Robert C. Leif
2002-06-28 12:53 ` Timetype Jacob Sparre Andersen

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