🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.borland
Article #144

Re: Date calculations in TP55

#144
From: Dr John Stockton
Date: Sat, 08 Dec 2001 16:19
61 lines
3741 bytes
JRS:  In article <MPG.167c96e9eb6c9e9e989910@news.clear.net.nz>, seen in
news:comp.lang.pascal.borland, Patrick Dunford <a47xxy@yahoo.co.nz>
wrote at Sat, 8 Dec 2001 08:30:03 :-
>
>I want to compare the date from a file (got with GetFTime) with today's 
>date and get the difference in days.

Before posting to a newsgroup, it is wise to read recent articles in it.
Most of your question has been answered in this newsgroup within the
last 7 days, in a thread "Subject: FREE inline date-math subr - only TWO
LINES long. Wow!".  Read the whole thread, though.

You should also read the relevant FAQ (but especially #57 A2; and the
methods in #119 can be beaten).

Evidently you can get the file date with GetFTime and UnpackTime; and
today with GetDate; you only need to be able to convert to a daycount,
and you know that the range 1980-2099 is all that need be handled.  The
100- and 400- year rules can therefore be omitted.

My <URL: http://www.merlyn.demon.co.uk/programs/dateprox.pas>, needs
<URL: http://www.merlyn.demon.co.uk/programs/version.pas>, tested with
<URL: http://www.merlyn.demon.co.uk/programs/mjd_date.pas>, has numerous
routines, including YMDtoMJD.

The following more limited method does not halt within 1900-03-01 to
2100-02-28, showing that in that range DV is calculated correctly.

uses dateprox ;

const ar : array [1..12] of integer
  = (2,33,61,92,122,153,183,214,245,275,306,336) ;

var DV, MJD : MJDate ; Y : integer ; M, D : byte ;

BEGIN ;
Writeln ;
for MJD := YMDtoMJD(1900, 02, 26) to YMDtoMJD(2100, 03, 03) do begin
  MJDtoYMD(MJD, Y, M, D) ;
  DV := (longint(y-1900)*1461) div 4 + ar[M] + D ;
  if (M<3) and (Y mod 4 = 0) then Dec(DV) ;
  DV := DV + 23783 -6*1461 ;
  Write(^M, MJD:10, DV:10, Y:10, M:3, D:3) ;
  if MJD<>DV then Readln ;
  end;
END.

The core of that is much the same as in YMD2MJD1 and JPC_MJD of
dateprox.pas.  N.B. dateprox is for TP7/BP7; but conversion to TP5.5
should not be difficult.


Newsgroups reversed; you have not been posting to Borland's proper
server, and they don't like cross-posts (weird); see their Guidelines on
their WWW site, and the end of Section 1 of out mFAQ.
 
-- 
� John Stockton, Surrey, UK.  jrs@merlyn.demon.co.uk   Turnpike v4.00   MIME. �
 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.
Technical Details
Message-ID: <KrmO2zEj2jE8Ewan@merlyn.demon.co.uk>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!dispose.news.demon.net!news.demon.co.uk!demon!merlyn.demon.co.uk!spam
References: <MPG.167c96e9eb6c9e9e989910@news.clear.net.nz>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111659,f55e76139518d000
X-Google-Attributes: gid111659,public
X-Google-Thread: 108ebd,f55e76139518d000
X-Google-Attributes: gid108ebd,public
X-Google-ArrivalTime: 2001-12-08 14:53:01 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!dispose.news.demon.net!news.demon.co.uk!demon!merlyn.demon.co.uk!spam
From: Dr John Stockton <spam@merlyn.demon.co.uk>
Newsgroups: comp.lang.pascal.borland,borland.public.turbopascal
Subject: Re: Date calculations in TP55
Date: Sat, 8 Dec 2001 16:19:47 +0000
Organization: Home, 'Surrey', UK
Message-ID: <KrmO2zEj2jE8Ewan@merlyn.demon.co.uk>
References: <MPG.167c96e9eb6c9e9e989910@news.clear.net.nz>
Reply-To: Dr John Stockton <reply@merlyn.demon.co.uk>
NNTP-Posting-Host: merlyn.demon.co.uk
X-NNTP-Posting-Host: merlyn.demon.co.uk:158.152.233.145
X-Trace: news.demon.co.uk 1007851979 nnrp-13:15491 NO-IDENT merlyn.demon.co.uk:158.152.233.145
X-Complaints-To: abuse@demon.net
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain;charset=iso-8859-1
X-Newsreader: Turnpike (32) Version 4.00  <FaPHOaas0ellLCXbR0oIxSiVaE>
Lines: 61