Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #56314
| From | Ron Aaron <rambamist@gmail.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Dates in Forth |
| Date | 2017-03-26 06:57 +0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <ob7e1p$5b6$1@dont-email.me> (permalink) |
| References | <ob6k7q$747$1@dont-email.me> <67b79ab1-50bf-408b-8386-8d97bb709535@googlegroups.com> |
On 26/03/2017 4:31, krishna.myneni@ccreweb.org wrote: > On Saturday, March 25, 2017 at 3:37:00 PM UTC-5, Charles Montgomery wrote: > ... >> A more interesting task, for which I have been unable to find a >> published Forth solution, is the inverse problem: given the JD or MJD. >> compute the day, month, and year in the Gregorian calendar. >> I have a solution which works, but that I am not happy with. Does it >> really have to be this complicated, or is there some number-theory tidbit >> that I am failing to recognize? >> >> : DJM4 ( Modified Julian Day -- year month day ) >> 51604 - 146097 /mod swap >> dup 146096 = IF drop 3 36524 ELSE 36524 /mod swap THEN >> 1461 /mod swap DUP 1460 = IF drop 3 366 ELSE 365 /mod swap 1+ THEN >> >R rot 100 * + rot 400 * + swap 4 * + 2000 + R> >> 5 * 3 - 153 /mod swap 5 / 1+ >> >R 3 + DUP >R 12 > IF 1 + R> 12 - ELSE R> THEN R> ; >> >> I hesitate to take up space on comp.lang.forth with a version with stack >> comments and an explanation of what on earth is going on, because it may >> Not be Of General Interest. I'd be happy to provide more details by email >> if anyone is interested. Or to post more if there is interest. > ... > > Yes, please. This will be a nice addition to a generic Forth toolbox. An explanation of what the code is doing would be appreciated. > > Krishna Wil Baden's toolbox has a version of this. It's based on the code in the "Calendrica" suite: https://www.cs.tau.ac.il/~nachum/calendar-book/index.shtml The "Calendrical Calculations" books are fascinating, IMO. Well worth reading if you're interested in calendar mathematics.
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Dates in Forth Charles Montgomery <cgm@physics.utoledo.edu> - 2017-03-25 16:36 -0400
Re: Dates in Forth Alex <alex@rivadpm.com> - 2017-03-25 20:45 +0000
Re: Dates in Forth "Elizabeth D. Rather" <erather@forth.com> - 2017-03-25 11:34 -1000
Re: Dates in Forth krishna.myneni@ccreweb.org - 2017-03-25 18:31 -0700
Re: Dates in Forth Ron Aaron <rambamist@gmail.com> - 2017-03-26 06:57 +0300
Re: Dates in Forth krishna.myneni@ccreweb.org - 2017-03-26 05:15 -0700
Re: Dates in Forth Mark Wills <markwills1970@gmail.com> - 2017-03-26 02:29 -0700
Dates in Forth lehs <skydda.barnen@gmail.com> - 2017-03-29 10:39 -0700
csiph-web