class Date
Public Class Methods
easter(year=self.today.year)
click to toggle source
# File lib/feast_fast/date.rb, line 3 def self.easter(year=self.today.year) # FeastFast::DB.data(year.to_i)[:easter] raise TypeError, 'expected fixnum' unless year.instance_of? Fixnum a = (19 * (year % 19) + 15) % 30 b = (2 * (year % 4) + 4 * (year % 7) + 6 * a + 6) % 7 c = a + b if c > 9 d = c - 9 # day m = 4 # month else d = 22 + c # day m = 3 # month end self.new(year, m, d) + 13 end
with_feasts(year, *statuses)
click to toggle source
# File lib/feast_fast/date.rb, line 19 def self.with_feasts(year, *statuses) FeastFast::DB.feasts(year, *statuses).keys.sort end
Public Instance Methods
easter?()
click to toggle source
# File lib/feast_fast/date.rb, line 30 def easter? self == FeastFast::DB.data(self.year)[:easter] end
fast()
click to toggle source
# File lib/feast_fast/date.rb, line 26 def fast @fast ||= FeastFast::DB.date(self)[:fast] end
fast?()
click to toggle source
# File lib/feast_fast/date.rb, line 34 def fast? self.fast.status != FeastFast::Fast::STATUS::NO end
feasts()
click to toggle source
# File lib/feast_fast/date.rb, line 23 def feasts @feasts ||= FeastFast::DB.date(self)[:feasts] end
feasts?()
click to toggle source
# File lib/feast_fast/date.rb, line 38 def feasts?() self.feasts.any? end
next_date(n=1)
click to toggle source
# File lib/feast_fast/date.rb, line 49 def next_date(n=1) self + n end
next_easter()
click to toggle source
# File lib/feast_fast/date.rb, line 73 def next_easter easter = self.class.easter(self.year) if easter > self easter else self.class.easter(self.year + 1) end end
next_sunday(step=1)
click to toggle source
# File lib/feast_fast/date.rb, line 52 def next_sunday(step=1) days_to_sunday = self.wday!=0 ? 7-self.wday : 0 days_to_sunday = days_to_sunday + 7*(step-1) result = self + days_to_sunday end
next_with_feast(*statuses)
click to toggle source
# File lib/feast_fast/date.rb, line 40 def next_with_feast(*statuses) self.class.with_feasts(self.year, *statuses).find{|d| d > self } || self.class.with_feasts(self.year + 1, *statuses).first end
prev_date(n=1)
click to toggle source
# File lib/feast_fast/date.rb, line 50 def prev_date(n=1) self - n end
prev_sunday(step=1)
click to toggle source
# File lib/feast_fast/date.rb, line 58 def prev_sunday(step=1) days_to_sunday = self.wday!=0 ? self.wday : 0 days_to_sunday = days_to_sunday + 7*(step-1) result = self - days_to_sunday end
prev_with_feast(*statuses)
click to toggle source
# File lib/feast_fast/date.rb, line 44 def prev_with_feast(*statuses) self.class.with_feasts(self.year, *statuses).reverse.find{|d| d < self } || self.class.with_feasts(self.year - 1, *statuses).last end
week_ago()
click to toggle source
# File lib/feast_fast/date.rb, line 70 def week_ago() weeks_ago end
week_since()
click to toggle source
# File lib/feast_fast/date.rb, line 71 def week_since() weeks_since end
weeks_ago(step=1)
click to toggle source
# File lib/feast_fast/date.rb, line 64 def weeks_ago(step=1) self - 7*step end
weeks_since(step=1)
click to toggle source
# File lib/feast_fast/date.rb, line 67 def weeks_since(step=1) self + 7*step end