Skip to content

Commit

Permalink
feat(core): variable with date support for predefined string and type…
Browse files Browse the repository at this point in the history
… in existingFormat
  • Loading branch information
tchiotludo committed Feb 15, 2022
1 parent 850c330 commit 004e08a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected static ZonedDateTime convert(Object value, ZoneId zoneId, String exist
}

if (existingFormat != null) {
return ZonedDateTime.parse((String) value, DateTimeFormatter.ofPattern(existingFormat));
return ZonedDateTime.parse((String) value, formatter(existingFormat));
}

return ZonedDateTime.parse((String) value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ void timestampCompare() throws IllegalVariableEvaluationException {
assertThat(render, is("true"));
}

@Test
void dateRfc() throws IllegalVariableEvaluationException {
String render = variableRenderer.render(
"{{ 'Tue, 08 Feb 2022 19:38:26 GMT' | date(existingFormat='rfc_1123_date_time', timeZone=\"Europe/Paris\") }}",
ImmutableMap.of(
"zoned", NOW
)
);

assertThat(render, is("2022-02-08T20:38:26.000000+01:00"));
}

@Test
void instantnano() throws IllegalVariableEvaluationException {
String render = variableRenderer.render(
Expand Down

0 comments on commit 004e08a

Please sign in to comment.