Skip to content

Commit f9973f1

Browse files
authored
fix: support 'localtime' as a timezone (#625)
1 parent e0d5a2f commit f9973f1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/main/java/com/google/cloud/spanner/pgadapter/session/PGSetting.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,9 @@ static String convertToValidZoneId(String value) {
458458
if ("utc".equalsIgnoreCase(value)) {
459459
return "UTC";
460460
}
461+
if ("localtime".equalsIgnoreCase(value)) {
462+
return ZoneId.systemDefault().getId();
463+
}
461464
for (String zoneId : ZoneId.getAvailableZoneIds()) {
462465
if (zoneId.equalsIgnoreCase(value)) {
463466
return zoneId;

src/test/java/com/google/cloud/spanner/pgadapter/JdbcMockServerTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,6 +2956,16 @@ public void testSetTimeZoneToServerDefault() throws SQLException {
29562956
}
29572957
}
29582958

2959+
@Test
2960+
public void testSetTimeZoneToLocaltime() throws SQLException {
2961+
try (Connection connection = DriverManager.getConnection(createUrl())) {
2962+
connection.createStatement().execute("set time zone 'atlantic/jan_mayen'");
2963+
verifySettingValue(connection, "timezone", "Atlantic/Jan_Mayen");
2964+
connection.createStatement().execute("set time zone localtime");
2965+
verifySettingValue(connection, "timezone", TimeZone.getDefault().getID());
2966+
}
2967+
}
2968+
29592969
@Test
29602970
public void testSetTimeZoneToDefault() throws SQLException {
29612971
try (Connection connection =

0 commit comments

Comments
 (0)