Skip to content

Instantly share code, notes, and snippets.

@abdulsattar
Last active August 29, 2015 13:56
Show Gist options
  • Save abdulsattar/8839726 to your computer and use it in GitHub Desktop.
Save abdulsattar/8839726 to your computer and use it in GitHub Desktop.
Timelogger

Develop a timelogger. It should allow you to record time spent doing a task and give you a summary of all the tasks you did on a given day/week.

Here's how it will work, you say timelogger <taskname>. <taskname> is the task you just did. You should store the current timestamp and the <taskname>. So, the time you spent on <taskname> is the difference between times of <taskname> and previous task. You won't count the amount of time for the very first task.

E.g.

$ timelogger arrived
$ timelogger coffee
$ timelogger school_one
$ timelogger lunch
$ timelogger school_one

In the above example, you ignore arrived. The amount of time spent on coffee is the difference between the times of coffee and arrived. Similarly for lunch. However, the time spent on school_one is the sum of school_one - coffee and school_one - lunch.

You should display the results prettily.

$ timelogger
0h 00m  arrived
0h 30m  coffee
4h 00m  school_one
1h 00m  lunch
4h 00m  school_one

The --date=2014-01-01 option must display timesheet for that particular date. (If there is no such option, display for today).

The --task=school_one option must display the total amount of time spent on that project on the given day.

timelogger --task=school_one
8h 00m school_one

Bonus points if you implement a date range. The --from=2014-01-01 and --to=2014-01-06 should display all the tasks from the from date to the to date. If only from option is given and no to option is given, default the to option to current day. And --task=school_one --from=2014-01-01 --to=2014-01-06 should display the total amount of time spent on school_one on all these days.

2014-01-06 8:30 arrived
2014-01-06 9:00 coffee
2014-01-06 1:00 school_one
2014-01-06 2:00 lunch
2014-01-06 6:00 school_one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment