lib/timetrap/cli.rb in timetrap-1.8.4 vs lib/timetrap/cli.rb in timetrap-1.8.5
- old
+ new
@@ -373,12 +373,17 @@
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
+ d = Chronic.parse( "last #{args['-s'] || Date.today.strftime("%B")}" )
+
beginning_of_month = Date.new( d.year, d.month )
- end_of_month = Date.new( d.year, d.month+1 ) - 1
+ end_of_month = if d.month == 12 # handle edgecase
+ Date.new( d.year + 1, 1) - 1
+ else
+ Date.new( d.year, d.month+1 ) - 1
+ end
args['-s'] = beginning_of_month.to_s
args['-e'] = end_of_month.to_s
display
end