Fixed offset for graphs with minutes in timezones

Timezone offset is now a double.

This fix seems very simple, and it kinda is.

HighCharts represents offset in minutes.
Java gives offset in milliseconds, and that was
incorrectly to be assumed as full hours, so the offset
was rounded to an integer. Using a double will allow
all kinds of offsets that still work with highcharts.

Fixes timezones like
- Nepal (GMT+05:45)
- Newfoundland Time (GMT-03:30)

Affects issues:
- Fixed #1652
This commit is contained in:
Risto Lahtela 2021-01-20 18:12:56 +02:00
parent 6758a56167
commit 2b737c9973

View File

@ -108,10 +108,10 @@ public class PlanConfig extends Config {
return foundTZ.orElse(TimeZone.getTimeZone(ZoneId.of("UTC")));
}
public int getTimeZoneOffsetHours() {
int offset = getTimeZone().getOffset(System.currentTimeMillis());
public double getTimeZoneOffsetHours() {
int offsetMs = getTimeZone().getOffset(System.currentTimeMillis());
int hourMs = (int) TimeUnit.HOURS.toMillis(1L);
return -offset / hourMs;
return -offsetMs * 1.0 / hourMs;
}
public Path getPageExportPath() {