Skip to content

Commit

Permalink
Merge pull request #1189 from HubSpot/revert-1188-fix-date-time-with-…
Browse files Browse the repository at this point in the history
…timezone

Revert "Fix date-time format with configured timezone."
  • Loading branch information
hs-lsong authored May 31, 2024
2 parents 6670a21 + 7cbf18f commit 8ff186e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
2 changes: 0 additions & 2 deletions src/main/java/com/hubspot/jinjava/lib/fn/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ public static String dateTimeFormat(Object var, String... format) {
zoneOffset = ((ZonedDateTime) var).getZone();
} else if (var instanceof PyishDate) {
zoneOffset = ((PyishDate) var).toDateTime().getZone();
} else if (interpreter != null) {
zoneOffset = interpreter.getConfig().getTimeZone();
}

if (var == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,4 @@ public void itUsesDeprecationDateIfNoDateProvided() {
JinjavaInterpreter.popCurrent();
}
}

@Test
public void itUsesTimezoneFromConfigToFormatString() {
Jinjava jinjava = new Jinjava(
JinjavaConfig
.newBuilder()
.withTimeZone(ZoneOffset.ofHours(+2))
.withLocale(new Locale("da"))
.build()
);
JinjavaInterpreter interpreter = jinjava.newInterpreter();
JinjavaInterpreter.pushCurrent(interpreter);
try {
long timestamp = 1718920800000L; // 2024-06-20 22:00:00 UTC
assertThat(filter.filter(timestamp, interpreter, "%b %d, %Y, at %I:%M %p"))
.isEqualTo("jun. 21, 2024, at 12:00 AM");
} finally {
JinjavaInterpreter.popCurrent();
}
}
}

0 comments on commit 8ff186e

Please sign in to comment.