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

[WIP] Letting the user specify a timeframe for the report and log commands #14

wants to merge 9 commits into
base: master


Copy link

gueorgui commented Nov 3, 2019

As I work with Chrono, I find myself wanting to be able to get reports and, at times, logs for not just the current day, week, month, or year, but also previous ones.

Example use case: It is now 1st November, and I need to invoice my client for work done in October. I want to run:

$ chrono report --month="2019-10"

This pull request implements such functionality, for --month, --week, and --year.

⚠️ This is my first time working with Go, so please don't hesitate to let me know if anything is missing or done the wrong way. This is why I'm sharing the PR here before it is complete.

TODO before merging

  • Let user specify month for month flag
  • Let user specify week for week flag
  • Let user specify year for year flag
  • Let user specify day
  • Make sure tests are working
  • Update documentation
@gueorgui gueorgui changed the title [WIP] Letting the user specify a timeframe for the report command [WIP] Letting the user specify a timeframe for the report and log commands Nov 3, 2019
// TODO: Is a 2006-01-01 date format the best way to specify a week?
func GetTimespanForWeek(date string) (time.Time, time.Time) {
parsed := SanitizeUserInput(date, "2006-01-02")
return now.With(parsed).BeginningOfWeek(), now.With(parsed).EndOfWeek()
Comment on lines +56 to +59

This comment has been minimized.

Copy link

gueorgui Nov 5, 2019


I would appreciate any input on the best way to specify a target week for a log or report. For now, using now.With(), we use the week that includes the day passed as parameter.

Another way I could imagine this working would be passing the week number, but that seems less intuitive for the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.