Module: TimeCrisis::Support::Change::Time
- Defined in:
- lib/time_crisis/support/change.rb
Instance Method Summary collapse
- #beginning_of_day ⇒ Object
- #beginning_of_month ⇒ Object
- #beginning_of_year ⇒ Object
- #change(options = {}) ⇒ Object
- #end_of_day ⇒ Object
- #end_of_month ⇒ Object
- #end_of_year ⇒ Object
Instance Method Details
#beginning_of_day ⇒ Object
68 69 70 |
# File 'lib/time_crisis/support/change.rb', line 68 def beginning_of_day change(:hour => 0, :min => 0, :sec => 0, :usec => 0) end |
#beginning_of_month ⇒ Object
59 60 61 |
# File 'lib/time_crisis/support/change.rb', line 59 def beginning_of_month change(:day => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0) end |
#beginning_of_year ⇒ Object
51 52 53 |
# File 'lib/time_crisis/support/change.rb', line 51 def beginning_of_year change(:month => 1, :day => 1, :hour => 0, :min => 0, :sec => 0) end |
#change(options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/time_crisis/support/change.rb', line 38 def change(={}) ::Time.send( utc? ? :utc_time : :local, [:year] || year, [:month] || month, [:day] || day, [:hour] || hour, [:min] || ([:hour] ? 0 : min), [:sec] || (([:hour] || [:min]) ? 0 : sec), [:usec] || (([:hour] || [:min] || [:sec]) ? 0 : usec) ) end |
#end_of_day ⇒ Object
72 73 74 |
# File 'lib/time_crisis/support/change.rb', line 72 def end_of_day change(:hour => 23, :min => 59, :sec => 59, :usec => 999999.999) end |
#end_of_month ⇒ Object
63 64 65 66 |
# File 'lib/time_crisis/support/change.rb', line 63 def end_of_month last_day = self.class.days_in_month(self.month, self.year) change(:day => last_day, :hour => 23, :min => 59, :sec => 59, :usec => 999999.999) end |
#end_of_year ⇒ Object
55 56 57 |
# File 'lib/time_crisis/support/change.rb', line 55 def end_of_year change(:month => 12,:day => 31,:hour => 23, :min => 59, :sec => 59) end |