From e0069bd02fa40bc5b7e1421f415f16125a93b77b Mon Sep 17 00:00:00 2001 From: "M. Waisberg" Date: Sun, 7 Jul 2024 08:34:31 +0300 Subject: [PATCH] Calendar constants. --- .../hebrewcalendar/HebrewDateFormatter.java | 6 +++--- .../zmanim/hebrewcalendar/JewishDate.java | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java index 71fa8f12..3c458cc5 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java @@ -772,15 +772,15 @@ public String formatMonth(JewishDate jewishDate) { final int month = jewishDate.getJewishMonth(); if (isHebrewFormat()) { if (jewishDate.isJewishLeapYear() && month == JewishDate.ADAR) { - return hebrewMonths[13] + (useGershGershayim ? GERESH : ""); // return Adar I, not Adar in a leap year + return hebrewMonths[JewishDate.ADAR_II] + (useGershGershayim ? GERESH : ""); // return Adar I, not Adar in a leap year } else if (jewishDate.isJewishLeapYear() && month == JewishDate.ADAR_II) { - return hebrewMonths[12] + (useGershGershayim ? GERESH : ""); + return hebrewMonths[JewishDate.ADAR] + (useGershGershayim ? GERESH : ""); } else { return hebrewMonths[month - 1]; } } else { if (jewishDate.isJewishLeapYear() && month == JewishDate.ADAR) { - return transliteratedMonths[13]; // return Adar I, not Adar in a leap year + return transliteratedMonths[JewishDate.ADAR_II]; // return Adar I, not Adar in a leap year } else { return transliteratedMonths[month - 1]; } diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java index eb47d309..ab2fcfe8 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java @@ -32,17 +32,17 @@ * href="http://en.wikipedia.org/wiki/Hillel_II">Hillel II's (Hakatan's) calendar (4119 in the Jewish Calendar / 359 * CE Julian as recorded by Rav Hai Gaon) would be just an * approximation. - * + * * This open source Java code was written by Avrom Finkelstien from his C++ * code. It was refactored to fit the KosherJava Zmanim API with simplification of the code, enhancements and some bug * fixing. - * + * * Some of Avrom's original C++ code was translated from * C/C++ code in * Calendrical Calculations by Nachum Dershowitz and Edward M. * Reingold, Software-- Practice & Experience, vol. 20, no. 9 (September, 1990), pp. 899- 928. Any method with the mark * "ND+ER" indicates that the method was taken from this source with minor modifications. - * + * * If you are looking for a class that implements a Jewish calendar version of the Calendar class, one is available from * the ICU (International Components for Unicode) project, formerly part of * IBM's DeveloperWorks. @@ -153,7 +153,7 @@ public class JewishDate implements Comparable, Cloneable { /** The number of chalakim (1080) in an hour.*/ private static final int CHALAKIM_PER_HOUR = 1080; /** The number of chalakim (25,920) in a 24-hour day .*/ - private static final int CHALAKIM_PER_DAY = 25920; // 24 * 1080 + private static final long CHALAKIM_PER_DAY = 25920; // 24 * 1080 /** The number of chalakim in an average Jewish month. A month has 29 days, 12 hours and 793 * chalakim (44 minutes and 3.3 seconds) for a total of 765,433 chalakim*/ private static final long CHALAKIM_PER_MONTH = 765433; // (29 * 24 + 12) * 1080 + 793 @@ -460,8 +460,8 @@ private static int getLastMonthOfJewishYear(int year) { */ public static int getJewishCalendarElapsedDays(int year) { long chalakimSince = getChalakimSinceMoladTohu(year, TISHREI); - int moladDay = (int) (chalakimSince / (long) CHALAKIM_PER_DAY); - int moladParts = (int) (chalakimSince - moladDay * (long) CHALAKIM_PER_DAY); + int moladDay = (int) (chalakimSince / CHALAKIM_PER_DAY); + int moladParts = (int) (chalakimSince - moladDay * CHALAKIM_PER_DAY); // delay Rosh Hashana for the 4 dechiyos return addDechiyos(year, moladDay, moladParts); } @@ -533,7 +533,7 @@ private static long getChalakimSinceMoladTohu(int year, int month) { * Returns the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu * to the Jewish year and month that this Object is set to. * - * @return the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu + * @return the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu */ public long getChalakimSinceMoladTohu() { return getChalakimSinceMoladTohu(jewishYear, jewishMonth); @@ -888,8 +888,8 @@ private static int moladToAbsDate(long chalakim) { */ public JewishDate(long molad) { absDateToDate(moladToAbsDate(molad)); - int conjunctionDay = (int) (molad / (long) CHALAKIM_PER_DAY); - int conjunctionParts = (int) (molad - conjunctionDay * (long) CHALAKIM_PER_DAY); + int conjunctionDay = (int) (molad / CHALAKIM_PER_DAY); + int conjunctionParts = (int) (molad - conjunctionDay * CHALAKIM_PER_DAY); setMoladTime(conjunctionParts); } @@ -1293,7 +1293,7 @@ public void forward(int field, int amount) { /** * Forward the Jewish date by the number of months passed in. - * FIXME: Deal with forwarding a date such as 30 Nissan by a month. 30 Iyar does not exist. This should be dealt with similar to + * FIXME: Deal with forwarding a date such as 30 Nissan by a month. 30 Iyar does not exist. This should be dealt with similar to * the way that the Java Calendar behaves (not that simple since there is a difference between add() or roll(). * * @throws IllegalArgumentException if the amount is less than 1