Class: Date
- Inherits:
-
Object
- Object
- Date
- Includes:
- Koyomi::Helper::Week
- Defined in:
- lib/koyomi/helper/date.rb
Constant Summary
Constants included from Koyomi::Helper::Week
Koyomi::Helper::Week::DEFAULT_WEEK_START, Koyomi::Helper::Week::WEEK_DAYS, Koyomi::Helper::Week::WEEK_START_RANGE, Koyomi::Helper::Week::WEEK_WDAYS
Instance Method Summary collapse
-
#month_info ⇒ Hash
monthly information.
-
#nth_month_week ⇒ Integer
nth week day of the month.
-
#nth_wday ⇒ Array
nth week, week day of the month.
-
#wday_name ⇒ Symbol
week day name.
-
#week_end?(week_start = nil) ⇒ Boolean
check week end?.
-
#week_start?(week_start = nil) ⇒ Boolean
check week start?.
-
#windex ⇒ Integer
week day index.
Methods included from Koyomi::Helper::Week
Instance Method Details
#month_info ⇒ Hash
monthly information
59 60 61 62 63 64 65 66 |
# File 'lib/koyomi/helper/date.rb', line 59 def month_info _info = {} _infos = self.nth_wday.dup _info[:nth] = _infos.shift _info[:wday] = _infos.shift _info end |
#nth_month_week ⇒ Integer
nth week day of the month
43 44 45 46 47 |
# File 'lib/koyomi/helper/date.rb', line 43 def nth_month_week _week = (self.day / WEEK_DAYS).to_i _fraction = (self.day % WEEK_DAYS) (_week + (_fraction == 0 ? 0 : 1)) end |
#nth_wday ⇒ Array
nth week, week day of the month
52 53 54 |
# File 'lib/koyomi/helper/date.rb', line 52 def nth_wday [self.nth_month_week, self.wday_name] end |
#wday_name ⇒ Symbol
week day name
36 37 38 |
# File 'lib/koyomi/helper/date.rb', line 36 def wday_name self.class.wday_name(self) end |
#week_end?(week_start = nil) ⇒ Boolean
check week end?
14 15 16 |
# File 'lib/koyomi/helper/date.rb', line 14 def week_end?(week_start = nil) self.class.week_ends?(self, week_start) end |
#week_start?(week_start = nil) ⇒ Boolean
check week start?
22 23 24 |
# File 'lib/koyomi/helper/date.rb', line 22 def week_start?(week_start = nil) self.class.week_starts?(self, week_start) end |
#windex ⇒ Integer
week day index
29 30 31 |
# File 'lib/koyomi/helper/date.rb', line 29 def windex self.class.windex(self) end |