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

fix day range parsing (zk-org/zk#382) #384

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
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
4 changes: 3 additions & 1 deletion internal/cli/filtering.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ func parseDayRange(date string) (start time.Time, end time.Time, err error) {
return
}

start = startOfDay(day)
// we add -1 second so that the day range ends at 23:59:59
// i.e, the 'new day' begins at 00:00:00
start = startOfDay(day).Add(time.Second * -1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the value of start before? 00:00:00 or 00:00:01 ?
If start was already 00:00:00 then it seems that subtracting a second should be done to from end.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logically that does make sense in how I would also think a day range should be. But the issue is that when a note is created without a time stamp in YAML, that it's given the time 00:00. But it would seem the time library considers 00:00 to be midnight of the upcoming change over to the next day.

So if the second was subtracted from the end, and you made a note without a time stamp today, it would appear in a query for notes being created tomorrow (even though I don't think that query exists? It's just to illustrate the point)

In any case, subtracing 1 second from the end of the day, causes the issue-382.tesh test to fail. That test is a note created date: 2024-01-24 (without a time stamp), and queried with zk list -q --created 2024-01-24.

Is there another way to work around this that keeps a more logical way of interpreting a day range?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the test: #385

end = start.AddDate(0, 0, 1)
return start, end, nil
}
Expand Down