lib/timetrap/cli.rb in timetrap-1.8.0 vs lib/timetrap/cli.rb in timetrap-1.8.1
- old
+ new
@@ -85,10 +85,14 @@
usage: t sheet [TIMESHEET]
* 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.
-r, --round Round output to 15 minute start and end times.
-y, --yes Noninteractive, assume yes as answer to all prompts.
@@ -332,9 +336,18 @@
end
end
def week
args['-s'] = Date.today.wday == 1 ? Date.today.to_s : Date.parse(Chronic.parse(%q(last monday)).to_s).to_s
+ 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