From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,47b877165af3dad0 X-Google-Attributes: gidf7344,public X-Google-Thread: fdd80,47b877165af3dad0 X-Google-Attributes: gidfdd80,public X-Google-Thread: ffc31,47b877165af3dad0 X-Google-Attributes: gidffc31,public X-Google-Thread: 1164f8,47b877165af3dad0 X-Google-Attributes: gid1164f8,public From: Pierre.Bru@spotimage.fr Subject: Re: Y2K Conversion of Date to Internal Format Date: 1998/08/20 Message-ID: <6rh64h$5j7$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 382962134 References: <35D8AD45.458E8C95@idirect.com> <01bdcac2$35061860$7df84018@fsys.wave.shaw.ca> <01bdcb38$5fecbf40$2e0f4018@fsys.wave.shaw.ca> <35DB845F.918A044@idirect.com> To: jhfine@idirect.com Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Thu Aug 20 12:51:29 1998 GMT Newsgroups: vmsnet.pdp-11,alt.sys.pdp11,comp.os.vms,comp.sys.dec X-Http-User-Agent: Mozilla/3.03Gold (X11; I; OpenVMS V7.0 DEC 3000 - M300X) via proxy gateway CERN-HTTPD/3.0 libwww/2.17 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