Als je denkt dat schrikkeljaren een verschrikking zijn,
dan schrik niet van de Herbreeuwse kalender,
die soms 13 maanden kent.
Zie http://www.jewfaq.org/calendr2.htm
The next step is to determine how many months are between your starting point and Tishri of the year of your end point. There are exactly 235 months in every 19-year cycle of leap years (12 12-month years plus 7 13-month years), but if your number of years is not evenly divisible by 19, then you will have to determine whether each remaining year is a regular year (12 months) or a leap year (13 months).
En what's in the name: http://www.jewishgen.org/jos/josdates.htm met
JOS Calendar Conversion
De link naar Java is snel gemaakt: http://www.icu-project.org/docs/papers/international_calendars_in_java.htmlJanuary is still Zero
You would think that when we deprecated most of Date and added the new Calendar class, we would have fixed Date's biggest annoyance: the fact that January is month 0. We certainly should have, but unfortunately we didn't. We were afraid that programmers would be confused if Date used zero-based months and Calendar used one-based months. And a few programmers probably would have been. But in hindsight, the fact that Calendar is still zero-based has caused an enormous amount of confusion, and it was probably the biggest single mistake in the Java international API's.
En ja IBM heeft een implementatie in Java van de Hebrew calendar:
http://source.icu-project.org/repos/icu/icu4j/tags/release-3-8-d02/src/com/ibm/icu/util/HebrewCalendar.java
Al moet ik eerlijk erkennen dat iik nog noot van het ICU project gehoord heb.
En dan dit stukje code uit deze source:
/*** Determine whether a given Hebrew year is a leap year
*
* The rule here is that if (year % 19) == 0, 3, 6, 8, 11, 14, or 17.
* The formula below performs the same test, believe it or not.
*/
private static final boolean isLeapYear(int year) {
//return (year * 12 + 17) % 19 >= 12;
int x = (year*12 + 17) % 19;
return x >= ((x < 0) ? -7 : 12);
Wie deze code binnen de minuut snapt, is zeker Java proof!
No comments:
Post a Comment