Skip to content

Commit

Permalink
Don't apply offset if zero
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Sep 9, 2023
1 parent 4244863 commit 0ff92a5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/src/main/java/org/jruby/RubyTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,9 @@ public static DateTimeZone getTimeZoneWithOffset(Ruby runtime, String zoneName,
// validate_zone_name
zoneName = zoneName.trim();

String zone = zoneName + offset;
String zone = zoneName;

if (offset != 0) zone = zone + offset;

DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
if (cachedZone != null) {
Expand All @@ -431,9 +433,13 @@ public static DateTimeZone getTimeZoneWithOffset(Ruby runtime, String zoneName,
private static DateTimeZone timeZoneWithOffset(String zoneName, int offset) {
if (zoneName.isEmpty()) {
return DateTimeZone.forOffsetMillis(offset);
} else {
return new FixedDateTimeZone(zoneName, null, offset, offset);
} else if (offset == 0) {
DateTimeZone zone = DateTimeZone.forID(zoneName);

if (zone != null) return zone;
}

return new FixedDateTimeZone(zoneName, null, offset, offset);
}

public RubyTime(Ruby runtime, RubyClass rubyClass) {
Expand Down

0 comments on commit 0ff92a5

Please sign in to comment.