Skip to content

Commit a5f1fea

Browse files
committed
better noon
1 parent 7ed669d commit a5f1fea

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,6 @@ protected Date getDateFromTime(double time, SolarEvent solarEvent) {
652652
cal.add(Calendar.DAY_OF_MONTH, 1);
653653
} else if (solarEvent == SolarEvent.MIDNIGHT && localTimeHours + hours < 12) {
654654
cal.add(Calendar.DAY_OF_MONTH, 1);
655-
} else if (solarEvent == SolarEvent.NOON && localTimeHours + hours > 24) {
656-
cal.add(Calendar.DAY_OF_MONTH, -1);
657655
}
658656

659657
cal.set(Calendar.HOUR_OF_DAY, hours);
@@ -764,6 +762,14 @@ public Date getLocalMeanTime(double hours) {
764762
return getTimeOffset(getDateFromTime(hours - timezoneOffsetMillis
765763
/ (double) HOUR_MILLIS, SolarEvent.SUNRISE), -getGeoLocation().getLocalMeanTimeOffset(calendar));
766764
}
765+
public Date getLocalMeanTime(double hours, SolarEvent solarEvent) {
766+
if (hours < 0 || hours >= 24) {
767+
throw new IllegalArgumentException("Hours must between 0 and 23.9999...");
768+
}
769+
long timezoneOffsetMillis = getCalendar().getTimeZone().getOffset(getCalendar().getTimeInMillis());
770+
return getTimeOffset(getDateFromTime(hours - timezoneOffsetMillis
771+
/ (double) HOUR_MILLIS, solarEvent), -getGeoLocation().getLocalMeanTimeOffset(calendar));
772+
}
767773

768774
/**
769775
* Adjusts the <code>Calendar</code> to deal with edge cases where the location crosses the antimeridian.

src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3364,7 +3364,7 @@ public Date getTzais96() {
33643364
* @see AstronomicalCalendar#getLocalMeanTime(double)
33653365
*/
33663366
public Date getFixedLocalChatzos() {
3367-
return getLocalMeanTime(12.0);
3367+
return getLocalMeanTime(12.0, SolarEvent.NOON);
33683368
}
33693369

33703370
/**

0 commit comments

Comments
 (0)