Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/com/kosherjava/zmanim/ZmanimCalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,7 @@ public void setCandleLightingOffset(double candleLightingOffset) {
*/
public boolean isAssurBemlacha(Instant currentTime, Instant tzais, boolean inIsrael) {
JewishCalendar jewishCalendar = new JewishCalendar();
jewishCalendar.setGregorianDate(getLocalDate().getYear(), getLocalDate().getMonthValue(),
getLocalDate().getDayOfMonth());
jewishCalendar.setGregorianDate(getLocalDate());

jewishCalendar.setInIsrael(inIsrael);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Calendar; // We still use the old Calendar.WEEKDAY constants

/**
* The JewishCalendar extends the JewishDate class and adds calendar methods.
Expand Down Expand Up @@ -506,12 +507,12 @@ public Parsha getUpcomingParshah() {
JewishCalendar clone = (JewishCalendar) clone();
int daysToShabbos = (Calendar.SATURDAY - getDayOfWeek() + 7) % 7;
if (getDayOfWeek() != Calendar.SATURDAY) {
clone.forward(Calendar.DATE, daysToShabbos);
clone.addDays(daysToShabbos);
} else {
clone.forward(Calendar.DATE, 7);
clone.addDays( 7);
}
while(clone.getParshah() == Parsha.NONE) { //Yom Kippur / Sukkos or Pesach with 2 potential non-parsha Shabbosim in a row
clone.forward(Calendar.DATE, 7);
clone.addDays(7);
}
return clone.getParshah();
}
Expand Down Expand Up @@ -1233,16 +1234,9 @@ public Instant getMoladAsInstant() {
int seconds = (int) moladSeconds;
int nanos = (int) ((moladSeconds - seconds) * 1_000_000_000); // convert remainder to nanos

ZonedDateTime moladZdt = ZonedDateTime.of(
molad.getGregorianYear(),
molad.getGregorianMonth() + 1, // 1-based FIXME
molad.getGregorianDayOfMonth(),
molad.getMoladHours(),
molad.getMoladMinutes(),
seconds,
nanos,
jerusalemStandardOffset
);
LocalTime time = LocalTime.of(molad.getMoladHours(),molad.getMoladMinutes(),seconds,nanos);

ZonedDateTime moladZdt = ZonedDateTime.of(molad.getLocalDate(),time,jerusalemStandardOffset);

// Har Habayis at a longitude of 35.2354 offset vs longitude 35 in standard time, so we subtract the time difference
// of 20.94 minutes (20 minutes and 56 seconds and 496 millis) to get to Standard time from local mean time
Expand Down Expand Up @@ -1402,9 +1396,9 @@ public boolean equals(Object object) {
if (this == object) {
return true;
}
if (!(object instanceof JewishCalendar)) {
return false;
}
if (object == null || getClass() != object.getClass()) {
return false;
}
JewishCalendar jewishCalendar = (JewishCalendar) object;
return getAbsDate() == jewishCalendar.getAbsDate() && getInIsrael() == jewishCalendar.getInIsrael();
}
Expand All @@ -1414,9 +1408,8 @@ public boolean equals(Object object) {
* @see Object#hashCode()
*/
public int hashCode() {
int result = 17;
result = 37 * result + getClass().hashCode(); // needed or this and subclasses will return identical hash
result += 37 * result + getAbsDate() + (getInIsrael() ? 1 : 3);
return result;
int result = Integer.hashCode(getAbsDate());
result = 31 * result + Boolean.hashCode(getInIsrael());
return result;
}
}
Loading
Loading