Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/monkey-patch/time.rb
Instance Method Summary collapse
- #start_of_century ⇒ Object
- #start_of_day ⇒ Object
- #start_of_decade ⇒ Object
- #start_of_half_day ⇒ Object
- #start_of_half_hour ⇒ Object
- #start_of_hour ⇒ Object
- #start_of_minute ⇒ Object
- #start_of_month ⇒ Object
- #start_of_second ⇒ Object
- #start_of_week ⇒ Object
- #start_of_year ⇒ Object
Instance Method Details
#start_of_century ⇒ Object
88 89 90 |
# File 'lib/monkey-patch/time.rb', line 88 def start_of_century Time.parse strftime "#{year - year % 100}-01-01 00:00:00 %z" end |
#start_of_day ⇒ Object
68 69 70 |
# File 'lib/monkey-patch/time.rb', line 68 def start_of_day Time.parse strftime "%Y-%m-%d 00:00:00 %z" end |
#start_of_decade ⇒ Object
84 85 86 |
# File 'lib/monkey-patch/time.rb', line 84 def start_of_decade Time.parse strftime "#{year - year % 10}-01-01 00:00:00 %z" end |
#start_of_half_day ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/monkey-patch/time.rb', line 60 def start_of_half_day if hour < 12 Time.parse strftime "%Y-%m-%d 00:00:00 %z" else Time.parse strftime "%Y-%m-%d 12:00:00 %z" end end |
#start_of_half_hour ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/monkey-patch/time.rb', line 48 def start_of_half_hour if min < 30 Time.parse strftime "%Y-%m-%d %H:00:00 %z" else Time.parse strftime "%Y-%m-%d %H:30:00 %z" end end |
#start_of_hour ⇒ Object
56 57 58 |
# File 'lib/monkey-patch/time.rb', line 56 def start_of_hour Time.parse strftime "%Y-%m-%d %H:00:00 %z" end |
#start_of_minute ⇒ Object
44 45 46 |
# File 'lib/monkey-patch/time.rb', line 44 def start_of_minute Time.parse strftime "%Y-%m-%d %H:%M:00 %z" end |
#start_of_month ⇒ Object
76 77 78 |
# File 'lib/monkey-patch/time.rb', line 76 def start_of_month Time.parse strftime "%Y-%m-01 00:00:00 %z" end |
#start_of_second ⇒ Object
40 41 42 |
# File 'lib/monkey-patch/time.rb', line 40 def start_of_second Time.parse strftime "%Y-%m-%d %H:%M:%S %z" end |
#start_of_week ⇒ Object
72 73 74 |
# File 'lib/monkey-patch/time.rb', line 72 def start_of_week start_of_day - wday.days end |
#start_of_year ⇒ Object
80 81 82 |
# File 'lib/monkey-patch/time.rb', line 80 def start_of_year Time.parse strftime "%Y-01-01 00:00:00 %z" end |