mirror of
https://github.com/plashchynski/crono.git
synced 2026-05-02 21:54:28 +02:00
Merge pull request #53 from acolyer/same_day
schedule on: today if at: time not passed
This commit is contained in:
@@ -48,6 +48,7 @@ module Crono
|
|||||||
def initial_day
|
def initial_day
|
||||||
return Time.now unless @on
|
return Time.now unless @on
|
||||||
day = Time.now.beginning_of_week.advance(days: @on)
|
day = Time.now.beginning_of_week.advance(days: @on)
|
||||||
|
day = day.change(time_atts)
|
||||||
return day if day.future?
|
return day if day.future?
|
||||||
@period.from_now.beginning_of_week.advance(days: @on)
|
@period.from_now.beginning_of_week.advance(days: @on)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -49,6 +49,16 @@ describe Crono::Period do
|
|||||||
expect(@period.next).to be_eql(tuesday)
|
expect(@period.next).to be_eql(tuesday)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should return today on the first run if not too late' do
|
||||||
|
@period = Crono::Period.new(1.week, on: :sunday, at: '22:00')
|
||||||
|
Timecop.freeze(Time.now.beginning_of_week.advance(days: 6)
|
||||||
|
.change(hour: 21, min: 0)) do
|
||||||
|
expect(@period.next).to be_eql(
|
||||||
|
Time.now.beginning_of_week.advance(days: 6).change(hour: 22, min: 0)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'in daily basis' do
|
context 'in daily basis' do
|
||||||
|
|||||||
Reference in New Issue
Block a user