Skip to content

Commit

Permalink
Add support for time zones with +00:00 and -00:00
Browse files Browse the repository at this point in the history
Fixes #2370
  • Loading branch information
monkey-mas authored and dain committed Jun 13, 2015
1 parent 7a686a0 commit 9df5461
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Expand Up @@ -225,6 +225,11 @@ else if (length > 2 && zoneId.startsWith("ut")) {
length = zoneId.length();
}

// (+/-)00:00 is UTC
if ("+00:00".equals(zoneId) || "-00:00".equals(zoneId)) {
return "utc";
}

// if zoneId matches XXX:XX, it is likely +HH:mm, so just return it
// since only offset time zones will contain a `:` character
if (length == 6 && zoneId.charAt(3) == ':') {
Expand Down Expand Up @@ -280,9 +285,7 @@ private static boolean isUtcEquivalentName(String zoneId)
zoneId.equals("gmt0") ||
zoneId.equals("greenwich") ||
zoneId.equals("universal") ||
zoneId.equals("zulu") ||
zoneId.equals("+00:00") ||
zoneId.equals("-00:00");
zoneId.equals("zulu");
}

private static String zoneIdForOffset(long offset)
Expand Down
Expand Up @@ -57,11 +57,15 @@ public void testUTC()
assertSame(TimeZoneKey.getTimeZoneKey("GMT0"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("GMT+0"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("GMT-0"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("GMT+00:00"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("GMT-00:00"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("+00:00"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("-00:00"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("etc/utc"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("etc/gmt"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("etc/gmt+0"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("etc/gmt+00:00"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("etc/gmt-00:00"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("etc/ut"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("etc/UT"), UTC_KEY);
assertSame(TimeZoneKey.getTimeZoneKey("etc/UCT"), UTC_KEY);
Expand Down

0 comments on commit 9df5461

Please sign in to comment.