normanj-bitquill commented on code in PR #3833:
URL: https://github.com/apache/calcite/pull/3833#discussion_r1667195994
##########
core/src/test/java/org/apache/calcite/util/format/postgresql/PostgresqlDateTimeFormatterTest.java:
##########
@@ -1311,6 +1314,610 @@ void testEraLowerCaseWithDots(String pattern) {
assertEquals("xii", PostgresqlDateTimeFormatter.toChar("rm", date4));
}
+ @Test void testToTimestampYYYYWithCommas() throws Exception {
+ assertEquals(
+ createDateTime(1, 1, 1, 0, 0, 0, 0),
+ PostgresqlDateTimeFormatter.toTimestamp("0,001", "Y,YYY", TIME_ZONE));
+ assertEquals(
+ createDateTime(2024, 1, 1, 0, 0, 0, 0),
+ PostgresqlDateTimeFormatter.toTimestamp("2,024", "Y,YYY", TIME_ZONE));
+ }
+
+ @Test void testToTimestampYYYY() throws Exception {
+ assertEquals(
+ createDateTime(1, 1, 1, 0, 0, 0, 0),
+ PostgresqlDateTimeFormatter.toTimestamp("0001", "YYYY", TIME_ZONE));
+ assertEquals(
+ createDateTime(1, 1, 1, 0, 0, 0, 0),
+ PostgresqlDateTimeFormatter.toTimestamp("1", "YYYY", TIME_ZONE));
+ assertEquals(
+ createDateTime(2024, 1, 1, 0, 0, 0, 0),
+ PostgresqlDateTimeFormatter.toTimestamp("2024", "YYYY", TIME_ZONE));
+ }
+
+ @Test void testToTimestampYYY() throws Exception {
+ assertEquals(
+ createDateTime(2001, 1, 1, 0, 0, 0, 0),
+ PostgresqlDateTimeFormatter.toTimestamp("001", "YYY", TIME_ZONE));
+ assertEquals(
+ createDateTime(2001, 1, 1, 0, 0, 0, 0),
+ PostgresqlDateTimeFormatter.toTimestamp("1", "YYY", TIME_ZONE));
+ assertEquals(
+ createDateTime(1987, 1, 1, 0, 0, 0, 0),
+ PostgresqlDateTimeFormatter.toTimestamp("987", "YYY", TIME_ZONE));
+ }
+
+ @Test void testToTimestampYY() throws Exception {
+ assertEquals(
+ createDateTime(2001, 1, 1, 0, 0, 0, 0),
+ PostgresqlDateTimeFormatter.toTimestamp("01", "YY", TIME_ZONE));
+ assertEquals(
+ createDateTime(2001, 1, 1, 0, 0, 0, 0),
+ PostgresqlDateTimeFormatter.toTimestamp("1", "YY", TIME_ZONE));
+ assertEquals(
+ createDateTime(2024, 1, 1, 0, 0, 0, 0),
+ PostgresqlDateTimeFormatter.toTimestamp("24", "YY", TIME_ZONE));
+ }
+
+ @Test void testToTimestampY() throws Exception {
+ assertEquals(
+ createDateTime(2001, 1, 1, 0, 0, 0, 0),
Review Comment:
Added some constants and used those in most places.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]