Theiling Online    Sitemap    Conlang Mailing List HQ   

Re: Programming a calendar system

From:Mark J. Reed <markjreed@...>
Date:Friday, May 14, 2004, 23:37
On Fri, May 14, 2004 at 07:21:36AM -0400, Carsten Becker @ school wrote:
> So if you do $value = gregoriantojd(01,01,1970), $value is > 2,440,588.
Ugh, one more thing to dislike about PHP. That should be (1970,01,01); is (03,04,1970) March 4th or April 3rd? But I don't seem to have such a function in my php (PHP 5.0.0RC1). Anyway, that function gives you the JD as of noon UTC on that date. All you need to do is convert the UTC time of day to a fraction and adjust by that. For example, today is May 14, 2004, which PHP will tell you is 2,453,140. Right now as I type this it's 7:25 PM Eastern time. Since we're currently in Daylight Savings, the difference from UTC is 4 hours, so it's 11:25 PM UTC, which is 11 hours and 25 minutes after noon. Since there are 60 minutes in an hour, that's 11 + 25/60 = 11 + 5/12 = 11.41666... etc hours. Since there are 24 hours in a day, that's 11.41666666/24 = 0.4756944444444444... of a day after noon. But that's fake precision since we only had the time to the nearest minute, which only gets you three digits after the decimal. So the current JD is 2,453,140.475 (always round down when dealing with time). -Mark