Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Programming languages > Help convert C function to Pascal function
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
21 7th December 06:07
dr john stockton
External User
 
Posts: 1
Default Help convert C function to Pascal function



JRS: In article <L8CdnSIHLfQUaaveRVn-og@comcast.com>, dated Sun, 25 Sep
2005 15:04:25, seen in news:comp.lang.pascal.borland, William J. Leary
Jr. <Bill_Leary@msn.com> posted :

Within the nominal validity range of DOS, 1980-2099, there is a Leap
Year every 4 years. It's easy enough to convert from years starting in
January to ones starting in March, and then the Leap Year correction is
just Year div 4.

For more on conversion of Y M D to DayCount and back, see
<URL:http://www.merlyn.demon.co.uk/daycount.htm>,
<URL:http://www.merlyn.demon.co.uk/zeller-c.htm> and linked pages; and
<URL:http://www.merlyn.demon.co.uk/programs/dateprox.pas>.

The date is *maintained* in DOS as a word count of days; ISTM a pity
that it's kept at an undefined address, unlike the time which is kept at
longint $40:$6C. In true DOS, that address can be found - my
<URL:http://www.merlyn.demon.co.uk/programs/int_test.pas> will do it -
but it's easier and safer to code the legitimate conversion.


function ZelCMJD(Y, M, D : word) : longint ;
begin { Inc(Y, 7e5) ; Dec(Result, 7e5*365.2425) ;; 153 = 13 + 5*28 }
if M<3 then begin Inc(M, 12) ; Dec(Y) end ;
ZelCMJD := longint(Y)*365 - 678973 + (D + (M*153-2) div 5 +
Y div 4 - Y div 100 + Y div 400) end {ZelCMJD} ;

The 7e5 bit is needed only for very old years. That gives local days
from 1858-11-17.

The OP will still need to consider Time Zone and Summer Time; and, if
the code is to be used in the US (or maybe Canada) both before and after
the end of next year, will have to allow for the recently-legislated
change in the US DST rules:
<URL:http://www.merlyn.demon.co.uk/uksumtim.htm>.


--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
  Reply With Quote


  sponsored links


22 7th December 06:08
william j leary jr
External User
 
Posts: 1
Default Help convert C function to Pascal function



Yes. I understand that as a simple solution. I also worked out the 100 and
400 rules, on paper, and had run across some notes about a millenia rule as
well, which I hadn't looked up yet, but I hadn't gotten around to actually
coding any of it by the time ((whatever the name was)) had posted his "leg
up" code, so I dropped it. It was getting to be a bit too much like work.


OK. Maybe mine actually wouldn't have been as opaque as I though it was going to be.

Very nice. I wasn't worrying about dates prior to 1970 because the original
C code didn't seem to be doing so either.


That's going to be a joyful annoyance. I expect to have to adjust four
computers, four PDAs and two camera for those.

- Bill
  Reply With Quote
23 7th December 06:09
dr john stockton
External User
 
Posts: 1
Default Help convert C function to Pascal function


JRS: In article <5oOdnfl-GsVSx6XeRVn-gA@comcast.com>, dated Mon, 26 Sep
2005 16:33:00, seen in news:comp.lang.pascal.borland, William J. Leary
Jr. <Bill_Leary@msn.com> posted :


There is no millennia rule, indeed no rule higher than 400, and there
never has been, except perhaps temporarily a 4000 year rule for certain
European revolutionaries. A 4000 year omission rule would be about
right; a 3200 year one would be quite good, but a 1000 year-rule would
over-correct and make matters worse, as the target is around 365.2422 days per year.
See <URL:http://www.merlyn.demon.co.uk/leapyear.htm>, the Papal Bull
/Inter Gravissimas/, and the Calendar Act 1751 which applies to the
American colonies (but expressly omits AU & NZ!).

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
  Reply With Quote
24 7th December 06:09
william j leary jr
External User
 
Posts: 1
Default Help convert C function to Pascal function


Thanks. I couldn't track anything down on it after reading one obscure
reference. As I recall it was "millennia" in the sense that it involved
some number of thousands of years rather than all cases of one thousand
years. May have been the four thousand you speak of.

- Bill
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666