AstronomicalCalendar has a problem with half hour timezones.

Java class AstronomicalCalendar is used by Zmanim Project
One of the users of Simple Luach Jewish calendar resides in Caracas, Venezuela.
This user reported a problem that day times are shown incorrectly – without half an hour difference.
The problem is that since 2007, Venezuela got timezone with -4.5 hours offset from GMT. I stated investigation on this issue and found that class AstronomicalCalendar incorrectly converts timezone offset. It rounds always to the lower number.

find the following function in the class:

private double getOffsetTime(double time) {
		boolean dst = getCalendar().getTimeZone().inDaylightTime(
				getCalendar().getTime());
		double dstOffset = 0;
		// be nice to Newfies and use a double
        double gmtOffset =  getCalendar().getTimeZone().getRawOffset()
/ (MINUTE_MILLIS*60);

        	if (dst) {
			dstOffset = getCalendar().getTimeZone().getDSTSavings()
					/ (MINUTE_MILLIS*60);
		}
		return time + gmtOffset + dstOffset;
	}

just change gmtOffset from double to float:

private double getOffsetTime(double time) {
		boolean dst = getCalendar().getTimeZone().inDaylightTime(
				getCalendar().getTime());
		double dstOffset = 0;
		// be nice to Newfies and use a double
        float gmtOffset =  (float) getCalendar().getTimeZone().getRawOffset()/ HOUR_MILLIS ;

        	if (dst) {
			dstOffset = getCalendar().getTimeZone().getDSTSavings()
					/ HOUR_MILLIS;
		}
		return time + gmtOffset + dstOffset;
	}

Leave a Reply

%d bloggers like this: