[LEAPSECS] Meeting with Wayne Whyte

Tony Finch dot at dotat.at
Tue Feb 1 06:49:02 EST 2011


On Tue, 1 Feb 2011, Mark Calabretta wrote:

>

> We all deal every day with a non-uniform and variable radix counting

> system - "30 days hath September, ...".


However the Gregorian calendar can be implemented in a few static lines of
code, which is orders of magnitude less than is required to handle dynamic
updates of the leap second table. The two are in no way comparable.

int greg2rd(int y, int m, int d) {
if (m > 2) m += 1; else m += 13, y -= 1;
return y*1461/4 - y/100 + y/400 + m*153/5 + d - 428;
}

void rg2greg(int d, int *py, int *pm, int *pd) {
int y, m;
d += 305;
y = d*400/146097 + 1;
y -= y*1461/4 - y/100 + y/400 > d;
d -= y*1461/4 - y/100 + y/400 - 31;
m = d*17/520;
d -= m*520/17;
if (m < 11) m += 2;
else m -= 10, y += 1;
*py = y, *pm = m, *pd = d;
}

Tony.
--
f.anthony.n.finch <dot at dotat.at> http://dotat.at/
HUMBER THAMES DOVER WIGHT PORTLAND: NORTH BACKING WEST OR NORTHWEST, 5 TO 7,
DECREASING 4 OR 5, OCCASIONALLY 6 LATER IN HUMBER AND THAMES. MODERATE OR
ROUGH. RAIN THEN FAIR. GOOD.


More information about the LEAPSECS mailing list