From: Pierre.Bru@spotimage.fr
To: jhfine@idirect.com
Subject: Re: Y2K Conversion of Date to Internal Format
Date: 1998/08/20 [thread overview]
Message-ID: <6rh64h$5j7$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 35DB845F.918A044@idirect.com
here is a DCL version of the R.G. Tantzen algorithm that convert gregorian
date to julian day number and back. all is integer arithmetic and 32-bit
integers.
this algorithm is year-2000-proof, leap-year-proof, century-leap-year-proof
and you can compute julain day with this algorithm back to the begining of
the gregorian calendar, october 15, 1582.
I can give you explanations for all these 'magic' numbers if you want.
Pierre.
$!------------------------------------------------------------------------------
$!
$! d/m/y -> julian
$
$ if m.gt.2
$ then
$ m = m - 3
$ else
$ m = m + 9
$ y = y - 1
$ endif
$
$ c = y / 100
$ y = y - 100*c
$
$ j = c*146097/4 + y*1461/4 + (m*153 + 2)/5 + d + 1721119
$
$!------------------------------------------------------------------------------
$ write sys$output "julian day: ''j'"
$!------------------------------------------------------------------------------
$!
$! julian -> d/m/y
$
$ j = j - 1721119
$
$ y = (4*j - 1)/146097
$ j = (4*j - 1)-146097*y
$ d = j/4
$
$ j = (4*d + 3)/1461
$ d = (4*d + 3)-1461*j
$ d = (d+4)/4
$
$ m = (5*d - 3)/153
$ d = (5*d - 3)-153*m
$ d = (d+5)/5
$
$ y = y*100 + j
$
$ if m.lt.10
$ then
$ m = m + 3
$ else
$ m = m - 9
$ y = y + 1
$ endif
$
$!------------------------------------------------------------------------------
$ write sys$output "''d' ''m' ''y'"
$!------------------------------------------------------------------------------
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
next prev parent reply other threads:[~1998-08-20 4:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-08-17 4:00 Y2K Conversion of Date to Internal Format Jerome Fine
1998-08-19 4:00 ` Rob Brown
1998-08-19 4:00 ` Rob Brown
1998-08-19 4:00 ` Jerome Fine
1998-08-20 4:00 ` Pierre.Bru [this message]
[not found] ` <199808201251.HAA30561@x8.dejanews.com>
1998-08-21 4:00 ` Jerome Fine
1998-08-21 4:00 ` D.Webb
1998-08-22 4:00 ` Brian Inglis
1998-08-23 4:00 ` Charles Richmond
1998-08-24 4:00 ` Martin Vorlaender
1998-08-24 4:00 ` Pierre.Bru
-- strict thread matches above, loose matches on Subject: below --
1998-08-15 4:00 Jerome Fine
1998-08-17 4:00 ` Kevin Handy
1998-08-17 4:00 ` Jim Becker
1998-08-20 4:00 ` George Cornelius
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox