mirror of
https://github.com/jimeh/time_ext.git
synced 2026-02-19 05:16:40 +00:00
added include_end option to #iterate
This commit is contained in:
@@ -72,13 +72,22 @@ describe "Time Iterations" do
|
||||
match = (0..23).map { |i| ((@now - (@now.hour).hours) + i.hours).beginning_of_hour }
|
||||
@now.map_each_hour.of_the(:day) { |time| time }.should == match
|
||||
@now.map_each_hour.of_the_day { |time| time }.should == match
|
||||
match = @now.beginning_of_month.map_beginning_of_each_hour(:include_start => true).until(@now.next_month.beginning_of_month) { |time| time }
|
||||
match = @now.beginning_of_month.map_beginning_of_each_hour(:include_start => true, :include_end => false).until(@now.next_month.beginning_of_month) { |time| time }
|
||||
@now.map_each_hour.of_the(:month) { |time| time }.should == match
|
||||
end
|
||||
|
||||
it "should iterate and respect the include_start option" do
|
||||
match = (0..5).map { |i| @now + i.hours }
|
||||
it "should iterate and respect the include_start and include_end options" do
|
||||
match = (1..6).map { |i| @now + i.hours }
|
||||
@now.map_each_hour.until(@now + 6.hours) { |time| time }.should == match
|
||||
match = (1..6).map { |i| @now + i.hours }
|
||||
@now.map_each_hour(:include_end => true).until(@now + 6.hours) { |time| time }.should == match
|
||||
@now.map_each_hour(:include_start => false).until(@now + 6.hours) { |time| time }.should == match
|
||||
match = (0..6).map { |i| @now + i.hours }
|
||||
@now.map_each_hour(:include_start => true).until(@now + 6.hours) { |time| time }.should == match
|
||||
match = (0..5).map { |i| @now + i.hours }
|
||||
@now.map_each_hour(:include_start => true, :include_end => false).until(@now + 6.hours) { |time| time }.should == match
|
||||
match = (0..6).map { |i| @now + i.hours }
|
||||
@now.map_each_hour(:include_start => true, :include_end => true).until(@now + 6.hours) { |time| time }.should == match
|
||||
end
|
||||
|
||||
it "should iterate and respect the beginning_of option" do
|
||||
|
||||
Reference in New Issue
Block a user