| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | calendar |
Hi, Brenda. PE> > Could you please explain in detail how this works? I have been able PE> > to understand parts of the algorithm but not the whole. PE> >PE> static int dow(int y, int m, int d) PE>Unfortunately not. It is all to do with maths though. Basically every 4 [...] PE>day of week. I just use someone else's code, as they've PE>figured out the maths already. Every year has 52 weeks and *1* day, except leap years which have 52 weeks and 2 days. So, pick a year that you know what dow January 1 is - eg 1/1/1900 was a Monday. Add 1 day for each year since then, and one more day for each leap year. Then add the days in the current year up to the date you're looking for. The remainder after dividing by 7 is the dow - 0 = Mon, etc. That's basically what the code does, plus taking into account the leap year oddities that Paul mentioned. Regards, FIM. * SLMR 2.1a * It's only a hobby ... only a hobby ... only a --- Maximus 2.01wb* Origin: Sydney PC Users Group - COMPAQ BBS (3:712/505) SEEN-BY: 711/934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.