Skip to content
Browse files

add month cli option

  • Loading branch information...
1 parent 042dfc7 commit 5db8b8a8298fc593488c8ff660110c607199f522 @rfunduk committed Feb 14, 2012
Showing with 20 additions and 0 deletions.
  1. +7 −0 README.md
  2. +13 −0 lib/timetrap/cli.rb
View
7 README.md
@@ -318,6 +318,13 @@ Commands
usage: ``t week [--ids] [--end DATE] [--format FMT] [TIMESHEET | all]``
+**month**
+ Shortcut for display with start date set to the beginning of this month
+ (or a specified month) and end date set to the end of the month.
+
+ usage: ``t month [--ids] [--start MONTH] [--format FMT] [TIMESHEET | all]``
+
+
Global Options
--------
View
13 lib/timetrap/cli.rb
@@ -87,6 +87,10 @@ module CLI
* week - Shortcut for display with start date set to monday of this week.
usage: t week [--ids] [--end DATE] [--format FMT] [SHEET | all]
+ * month - Shortcut for display with start date set to the beginning of either
+ this month or a specified month.
+ usage: t month [--ids] [--start MONTH] [--format FMT] [SHEET | all]
+
OTHER OPTIONS
-h, --help Display this help.
@@ -337,6 +341,15 @@ def week
display
end
+ def month
+ d = Chronic.parse( "last #{args['-s'] || Date.today.strftime("%B")}" ).to_date
+ beginning_of_month = Date.new( d.year, d.month )
+ end_of_month = Date.new( d.year, d.month+1 ) - 1
+ args['-s'] = beginning_of_month.to_s
+ args['-e'] = end_of_month.to_s
+ display
+ end
+
private
def unused_args

0 comments on commit 5db8b8a

Please sign in to comment.
Something went wrong with that request. Please try again.