Describe the bug
Incomplete format = format which doesn't provide complete date and/or time part of datetime.
To Reproduce
Steps to reproduce the behavior:
"1999-10-20 15" with format "yyyy-MM-dd mm" parsed as 1999-10-20 00:00:00 (minute is missing)
"1999 10:20" with format "yyyy HH:mm" parsed as 1970-01-01 10:20:00 (year is missing)
Expected behavior
"1999-10-20 15" with format "yyyy-MM-dd mm" parsed as 1999-10-20 00:15:00
"1999 10:20" with format "yyyy HH:mm" parsed as 1999-01-01 10:20:00
Plugins
No
Screenshots
No
Host/Environment (please complete the following information):
main @ 3254efd
Additional context
This adds some limitations to feature added in opensearch-project/sql#1821
See tests below (diff: incomplete_formats.diff.txt):
public void testCustomIncompleteFormats_incompleteTime() {
var formatter = DateFormatter.forPattern("yyyy-MM-dd mm");
TemporalAccessor accessor = formatter.parse("1999-10-20 15");
var parsed = DateFormatters.from(accessor).withZoneSameLocal(ZoneId.of("UTC")).toLocalDateTime();
assertEquals(LocalDateTime.of(1999, 10, 20, 0, 15, 0), parsed);
// ^^
}
public void testCustomIncompleteFormats_incompleteDate() {
var formatter = DateFormatter.forPattern("yyyy HH:mm");
TemporalAccessor accessor = formatter.parse("1999 10:20");
var parsed = DateFormatters.from(accessor).withZoneSameLocal(ZoneId.of("UTC")).toLocalDateTime();
assertEquals(LocalDateTime.of(1999, 1, 1, 10, 20, 0), parsed);
// ^^
}
Describe the bug
Incomplete format = format which doesn't provide complete date and/or time part of datetime.
To Reproduce
Steps to reproduce the behavior:
"1999-10-20 15"with format"yyyy-MM-dd mm"parsed as1999-10-20 00:00:00(minute is missing)"1999 10:20"with format"yyyy HH:mm"parsed as1970-01-01 10:20:00(year is missing)Expected behavior
"1999-10-20 15"with format"yyyy-MM-dd mm"parsed as1999-10-20 00:15:00"1999 10:20"with format"yyyy HH:mm"parsed as1999-01-01 10:20:00Plugins
No
Screenshots
No
Host/Environment (please complete the following information):
main@ 3254efdAdditional context
This adds some limitations to feature added in opensearch-project/sql#1821
See tests below (diff: incomplete_formats.diff.txt):