Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

I can no longer support Date objects

This is because they come without zone information, and have a tendency to be unreliable.

For best results, use a TimeWithZone object.
  • Loading branch information...
commit 7013b7d2bff3a0d632144b90fd827d2035da00bf 1 parent 1529550
@radar authored
View
11 lib/by_star/by_day.rb
@@ -9,25 +9,22 @@ def by_day(*args)
end
def today(options={})
- by_day_Time_or_Date(Time.zone.now, options)
+ by_day_Time(Time.zone.now, options)
end
def yesterday(options={})
- by_day_Time_or_Date(Time.zone.now.yesterday, options)
+ by_day_Time(Time.zone.now.yesterday, options)
end
def tomorrow(options={})
- by_day_Time_or_Date(Time.zone.now.tomorrow, options)
+ by_day_Time(Time.zone.now.tomorrow, options)
end
private
- def by_day_Time_or_Date(time, options)
+ def by_day_Time(time, options)
between(time.beginning_of_day, time.end_of_day, options)
end
- alias_method :by_day_Time, :by_day_Time_or_Date
- alias_method :by_day_Date, :by_day_Time_or_Date
-
end
end
View
4 lib/by_star/by_fortnight.rb
@@ -13,7 +13,7 @@ def by_fortnight(*args)
private
- def by_fortnight_Time_or_Date(time, options={})
+ def by_fortnight_Time(time, options={})
# We want to get the current fortnight and so...
# We need to find the current week number and take one from it,
# so that we are correctly offset from the start of the year.
@@ -22,8 +22,6 @@ def by_fortnight_Time_or_Date(time, options={})
start_time = time.beginning_of_year + (time.strftime("%U").to_i - 1).weeks
between(start_time, (start_time + 2.weeks).end_of_day, options)
end
- alias_method :by_fortnight_Time, :by_fortnight_Time_or_Date
- alias_method :by_fortnight_Date, :by_fortnight_Time_or_Date
def by_fortnight_String_or_Fixnum(weeks, options={})
weeks = weeks.to_i
View
4 spec/by_star/by_day_spec.rb
@@ -9,10 +9,6 @@ def posts_count(*args)
posts_count.should eql(5)
end
- it "should be able to find a post by a given date" do
- posts_count(Date.today).should eql(5)
- end
-
it "should be able to find a post by a given date in last year" do
posts_count(:year => Time.zone.now.year - 1).should eql(1)
end
View
4 spec/by_star/by_fortnight_spec.rb
@@ -28,10 +28,6 @@ def posts_count(*args)
posts_count(2.weeks.ago).should eql(3)
end
- it "should be able to find posts if given a Date object" do
- posts_count(Date.today).should eql(8)
- end
-
it "should be able to find posts for a given fortnight in a year" do
posts_count(0, :year => Time.zone.now.year - 1).should eql(1)
end
Please sign in to comment.
Something went wrong with that request. Please try again.