Class: Time
- Inherits:
-
Object
- Object
- Time
- Extended by:
- ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods
- Includes:
- ActiveSupport::CoreExtensions::Time::Calculations
- Defined in:
- lib/dated_backup/extensions/time.rb
Class Method Summary collapse
Instance Method Summary collapse
- #days_in_month ⇒ Object
- #each_day_in_month ⇒ Object
- #end_of_day ⇒ Object (also: #at_end_of_day)
- #end_of_month ⇒ Object (also: #at_end_of_month)
- #end_of_week ⇒ Object (also: #at_end_of_week)
- #end_of_year ⇒ Object (also: #at_end_of_year)
- #last_week ⇒ Object
- #to_string ⇒ Object
- #week ⇒ Object
Class Method Details
.epoch ⇒ Object
8 9 10 |
# File 'lib/dated_backup/extensions/time.rb', line 8 def epoch Time.at(0) end |
Instance Method Details
#days_in_month ⇒ Object
51 52 53 |
# File 'lib/dated_backup/extensions/time.rb', line 51 def days_in_month self.class.days_in_month(self.month, self.year) end |
#each_day_in_month ⇒ Object
45 46 47 48 49 |
# File 'lib/dated_backup/extensions/time.rb', line 45 def each_day_in_month 1.upto(days_in_month) do |day_num| yield beginning_of_month + (day_num - 1).day end end |
#end_of_day ⇒ Object Also known as: at_end_of_day
16 17 18 |
# File 'lib/dated_backup/extensions/time.rb', line 16 def end_of_day tomorrow.beginning_of_day - 1 end |
#end_of_month ⇒ Object Also known as: at_end_of_month
20 21 22 |
# File 'lib/dated_backup/extensions/time.rb', line 20 def end_of_month next_month.beginning_of_month - 1 end |
#end_of_week ⇒ Object Also known as: at_end_of_week
28 29 30 |
# File 'lib/dated_backup/extensions/time.rb', line 28 def end_of_week next_week.beginning_of_week - 1 end |
#end_of_year ⇒ Object Also known as: at_end_of_year
24 25 26 |
# File 'lib/dated_backup/extensions/time.rb', line 24 def end_of_year next_year.beginning_of_year - 1 end |
#last_week ⇒ Object
32 33 34 |
# File 'lib/dated_backup/extensions/time.rb', line 32 def last_week 1.week.ago.beginning_of_week end |
#to_string ⇒ Object
55 56 57 |
# File 'lib/dated_backup/extensions/time.rb', line 55 def to_string strftime("%Y-%m-%d-%Hh-%Mm-%Ss") end |
#week ⇒ Object
41 42 43 |
# File 'lib/dated_backup/extensions/time.rb', line 41 def week beginning_of_week...end_of_week end |