Skip to content

Commit

Permalink
Fix for #161
Browse files Browse the repository at this point in the history
  • Loading branch information
samg committed Jul 27, 2017
1 parent 93a64a7 commit 729513c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/timetrap/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def week
d = Chronic.parse( args['-s'] || Date.today )

today = Date.new( d.year, d.month, d.day )
end_of_week = Date.new( d.year, d.month, d.day + 6 )
end_of_week = today + 6
last_week_start = Date.parse(Chronic.parse('last '.concat(Config['week_start']).to_s, :now => today).to_s)
args['-s'] = today.wday == Date.parse(Config['week_start']).wday ? today.to_s : last_week_start.to_s
args['-e'] = end_of_week.to_s
Expand Down
14 changes: 14 additions & 0 deletions spec/timetrap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,20 @@ def output
before do
with_stubbed_config 'week_start' => week_start_config
end

#https://github.com/samg/timetrap/issues/161
it "should work at the end of the month" do
Date.should_receive(:today).and_return(Date.new(2017, 7, 30))

create_entry(
:start => Time.local(2017, 7, 29, 1, 2, 3),
:end => Time.local(2017, 7, 29, 2, 2, 3)
)
invoke "week"
$stdout.string.should include 'Jul 29, 2017'

end

it "should not show entries prior to defined start of week" do
create_entry(
:start => Time.local(2012, 2, 5, 1, 2, 3),
Expand Down

0 comments on commit 729513c

Please sign in to comment.