🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java.programmer
Article #424

Re: Days between GregorianCalendars

#424
From: cameron_cp
Date: Fri, 31 Jul 1998 00:00
45 lines
2233 bytes
In article <35C07780.DF0F02D4@bigfoot.com>,
  Dag Welinder <welinder@bigfoot.com> wrote:
> Hello!
>
> Is it possible to compute the number of days between two dates? I have
> two instances of GregorianCalendar, each containing a date. Can I
> compute the number of days between these two dates?

  Translate the dates to Julian numbers and subtract the two.

  // Quick and Dirty translation from an older
  // turbo pascal function
  // UNTESTED - see original funciton

  int Julian(int M, int D,int Y) {
    int j2; int ju;
    j2 = (M - 14) / 12;
    ju = D - 32075 + (1461 * (Y + 4800 + j2) / 4);
    ju = ju + (367 * (M - 2 - j2 * 12) / 12);
    ju = ju - (3 * ( (Y + 4900 + j2) / 100) / 4);

    return ju;
  }

  // original function
  function dateType.Julian( mo, da, yr: integer): LongInt;
  var     i, j, k, j2, ju: longInt;
  begin
       i := yr;     j := mo;     k := da;
       j2 := ( (j - 14) div 12 );
       ju := k - 32075 + (1461 * ( i + 4800 + j2 ) div 4 );
       ju := ju + ( 367 * (j - 2 - j2 * 12) div 12);
       ju := ju - (3 * ( (i + 4900 + j2) div 100) div 4);
       Julian := ju;
  end;  { Jul }



--
The Idiot's Guide To Everything (ComputerRelated)
http://members.tripod.com/~igte
=================================================

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum
Technical Details
Message-ID: <6pt3il$66i$1@nnrp1.dejanews.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <35C07780.DF0F02D4@bigfoot.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,14895c81839f4d37
X-Google-Attributes: gidf74b3,public
X-Google-Thread: 113ae9,14895c81839f4d37
X-Google-Attributes: gid113ae9,public
X-Google-Thread: 10a146,14895c81839f4d37
X-Google-Attributes: gid10a146,public
From: cameron_cp@my-dejanews.com
Subject: Re: Days between GregorianCalendars
Date: 1998/07/31
Message-ID: <6pt3il$66i$1@nnrp1.dejanews.com>
X-Deja-AN: 376746021
References: <35C07780.DF0F02D4@bigfoot.com>
Organization: Deja News - The Leader in Internet Discussion
X-Article-Creation-Date: Fri Jul 31 18:48:52 1998 GMT
Newsgroups: comp.lang.java.programmer,comp.lang.java.help,borland.public.jbuilder.java.language
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)