Skip to content

Commit 181ba21

Browse files
committed
Add a test.
1 parent e128797 commit 181ba21

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/test/java/com/hubspot/jinjava/lib/filter/DateTimeFormatFilterTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,24 @@ public void itUsesDeprecationDateIfNoDateProvided() {
204204
JinjavaInterpreter.popCurrent();
205205
}
206206
}
207+
208+
@Test
209+
public void itUsesTimezoneFromConfigToFormatString() {
210+
Jinjava jinjava = new Jinjava(
211+
JinjavaConfig
212+
.newBuilder()
213+
.withTimeZone(ZoneOffset.ofHours(+2))
214+
.withLocale(new Locale("da"))
215+
.build()
216+
);
217+
JinjavaInterpreter interpreter = jinjava.newInterpreter();
218+
JinjavaInterpreter.pushCurrent(interpreter);
219+
try {
220+
long timestamp = 1718920800000L; // 2024-06-20 22:00:00 UTC
221+
assertThat(filter.filter(timestamp, interpreter, "%b %d, %Y, at %I:%M %p"))
222+
.isEqualTo("jun. 21, 2024, at 12:00 AM");
223+
} finally {
224+
JinjavaInterpreter.popCurrent();
225+
}
226+
}
207227
}

0 commit comments

Comments
 (0)