Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dayOfYearParser #197

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test invalid values
recidinick committed Mar 28, 2024
commit 02629570bd29ef384fc1cdc856d5355fe3871c0e
2 changes: 1 addition & 1 deletion internal/function_time_parser.go
Original file line number Diff line number Diff line change
@@ -746,7 +746,7 @@
}

func dayOfYearParser(text []rune, t *time.Time) (int, error) {
progress, d, err := parseDigitRespectingOptionalPlaces(text, 0, 366)
progress, d, err := parseDigitRespectingOptionalPlaces(text, 1, 366)
if err != nil {
return 0, fmt.Errorf("could not parse day of year number: %s", err)
}
@@ -756,9 +756,9 @@
*t = time.Date(
year,
stubDate.Month(),
int(stubDate.Day()),

Check failure on line 759 in internal/function_time_parser.go

GitHub Actions / lint

unnecessary conversion (unconvert)
int(t.Hour()),

Check failure on line 760 in internal/function_time_parser.go

GitHub Actions / lint

unnecessary conversion (unconvert)
int(t.Minute()),

Check failure on line 761 in internal/function_time_parser.go

GitHub Actions / lint

unnecessary conversion (unconvert)
int(t.Second()),
int(t.Nanosecond()),
t.Location(),
10 changes: 10 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
@@ -4170,6 +4170,16 @@ SELECT date, EXTRACT(ISOYEAR FROM date), EXTRACT(YEAR FROM date), EXTRACT(MONTH
query: `SELECT PARSE_DATE("%d", "0")`,
expectedErr: "error parsing [0] with format [%d]: could not parse day number: part [0] is less than minimum value [1]",
},
{
name: "parse date exceeding day of year maximum",
query: `SELECT PARSE_DATE("%j", "367")`,
expectedErr: "error parsing [367] with format [%j]: could not parse day of year number: part [367] is greater than maximum value [366]",
},
{
name: "parse date beneath day of year minimum",
query: `SELECT PARSE_DATE("%j", "0")`,
expectedErr: "error parsing [0] with format [%j]: could not parse day of year number: part [0] is less than minimum value [1]",
},
{
name: "parse date with single-digit month %m",
query: `SELECT PARSE_DATE("%m", "03"), PARSE_DATE("%m", "3"), PARSE_DATE("%m%Y", "032024")`,