Module: RiCal::PropertyValue::DateTime::TimeMachine
- Included in:
- RiCal::PropertyValue::DateTime
- Defined in:
- lib/ri_cal/property_value/date_time/time_machine.rb
Overview
-
??2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
Methods for DateTime which support getting values at different point in time.
Instance Method Summary (collapse)
-
- (Object) advance(options)
:nodoc:.
-
- (Object) at_end_of_iso_year(wkst)
Return a DATE_TIME value representing the same time on the last day of the ISO year with weeks starting on wkst containing the receiver.
-
- (Object) at_start_of_iso_year(wkst)
Return a DATE_TIME value representing the same time on the first day of the ISO year with weeks starting on wkst containing the receiver.
-
- (Object) at_start_of_next_iso_year(wkst)
Return a DATE_TIME value representing the same time on the first day of the ISO year with weeks starting on wkst after the ISO year containing the receiver.
-
- (Object) at_start_of_week_with_wkst(wkst)
Return a DATE-TIME property representing the receiver on a different day (if necessary) so that the result is the first day of the ISO week starting on the wkst day containing the receiver.
-
- (Object) change(options)
:nodoc:.
-
- (Object) change_day(new_day)
:nodoc:.
-
- (Object) change_hour(new_hour)
:nodoc:.
-
- (Object) change_min(new_min)
:nodoc:.
-
- (Object) change_month(new_month)
:nodoc:.
-
- (Object) change_sec(new_sec)
:nodoc:.
-
- (Object) change_year(new_year)
:nodoc:.
-
- (Object) end_of_day
Return a DATE_TIME value representing the last second of the day containing the receiver.
-
- (Object) end_of_hour
Return a DATE_TIME value representing the last second of the hour containing the receiver.
-
- (Object) end_of_iso_year(wkst)
Return a DATE_TIME value representing the last second of the last day of the ISO year with weeks starting on wkst containing the receiver.
-
- (Object) end_of_minute
Return a DATE_TIME value representing the last second of the minute containing the receiver.
-
- (Object) end_of_month
Return a DATE_TIME value representing the last second of the month containing the receiver.
-
- (Object) end_of_week_with_wkst(wkst)
Return a DATE_TIME value representing the last second of the ISO week starting with wkst containing the receiver.
-
- (Object) end_of_year
Return a DATE_TIME value representing the last second of the month containing the receiver.
-
- (Object) in_month(month)
Return a DATE-TIME representing the same time, on the same day of the month in month.
-
- (Boolean) in_week_starting?(date)
Return a DATE-TIME property representing the receiver on a different day (if necessary) so that the result is within the 7 days starting with date.
-
- (Object) start_of_day
Return a DATE_TIME value representing the first second of the day containing the receiver.
-
- (Object) start_of_hour
Return a DATE_TIME value representing the first second of the hour containing the receiver.
-
- (Object) start_of_minute
Return a DATE_TIME value representing the first second of the minute containing the receiver.
-
- (Object) start_of_month
Return a DATE_TIME value representing the first second of the month containing the receiver.
-
- (Object) start_of_week_with_wkst(wkst)
Return a Ruby Date representing the first day of the ISO week starting with wkst containing the receiver.
-
- (Object) start_of_year
Return a DATE_TIME value representing the first second of the month containing the receiver.
Instance Method Details
- (Object) advance(options)
:nodoc:
9 10 11 12 13 14 15 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 9 def advance() # :nodoc: PropertyValue::DateTime.new(timezone_finder, :value => @date_time_value.advance(), :tzid => @tzid, :params =>(params ? params.dup : nil) ) end |
- (Object) at_end_of_iso_year(wkst)
Return a DATE_TIME value representing the same time on the last day of the ISO year with weeks starting on wkst containing the receiver
131 132 133 134 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 131 def at_end_of_iso_year(wkst) num_weeks = @date_time_value.iso_weeks_in_year(wkst) at_start_of_iso_year(wkst).advance(:weeks => (num_weeks - 1), :days => 6) end |
- (Object) at_start_of_iso_year(wkst)
Return a DATE_TIME value representing the same time on the first day of the ISO year with weeks starting on wkst containing the receiver
124 125 126 127 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 124 def at_start_of_iso_year(wkst) start_of_year = @date_time_value.iso_year_start(wkst) change(:year => start_of_year.year, :month => start_of_year.month, :day => start_of_year.day) end |
- (Object) at_start_of_next_iso_year(wkst)
Return a DATE_TIME value representing the same time on the first day of the ISO year with weeks starting on wkst after the ISO year containing the receiver
138 139 140 141 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 138 def at_start_of_next_iso_year(wkst) num_weeks = @date_time_value.iso_weeks_in_year(wkst) at_start_of_iso_year(wkst).advance(:weeks => num_weeks) end |
- (Object) at_start_of_week_with_wkst(wkst)
Return a DATE-TIME property representing the receiver on a different day (if necessary) so that the result is the first day of the ISO week starting on the wkst day containing the receiver.
58 59 60 61 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 58 def at_start_of_week_with_wkst(wkst) date = @date_time_value.start_of_week_with_wkst(wkst) change(:year => date.year, :month => date.month, :day => date.day) end |
- (Object) change(options)
:nodoc:
17 18 19 20 21 22 23 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 17 def change() # :nodoc: PropertyValue::DateTime.new(timezone_finder, :value => @date_time_value.change(), :tzid => @tzid, :params => (params ? params.dup : nil) ) end |
- (Object) change_day(new_day)
:nodoc:
37 38 39 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 37 def change_day(new_day) #:nodoc: change(:day => new_day) end |
- (Object) change_hour(new_hour)
:nodoc:
33 34 35 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 33 def change_hour(new_hour) #:nodoc: change(:hour => new_hour) end |
- (Object) change_min(new_min)
:nodoc:
29 30 31 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 29 def change_min(new_min) #:nodoc: change(:min => new_min) end |
- (Object) change_month(new_month)
:nodoc:
41 42 43 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 41 def change_month(new_month) #:nodoc: change(:month => new_month) end |
- (Object) change_sec(new_sec)
:nodoc:
25 26 27 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 25 def change_sec(new_sec) #:nodoc: change(:sec => new_sec) end |
- (Object) change_year(new_year)
:nodoc:
45 46 47 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 45 def change_year(new_year) #:nodoc: change(:year => new_year) end |
- (Object) end_of_day
Return a DATE_TIME value representing the last second of the day containing the receiver
88 89 90 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 88 def end_of_day change(:hour => 23, :min => 59, :sec => 59) end |
- (Object) end_of_hour
Return a DATE_TIME value representing the last second of the hour containing the receiver
78 79 80 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 78 def end_of_hour change(:min => 59, :sec => 59) end |
- (Object) end_of_iso_year(wkst)
Return a DATE_TIME value representing the last second of the last day of the ISO year with weeks starting on wkst containing the receiver
145 146 147 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 145 def end_of_iso_year(wkst) at_end_of_iso_year(wkst).end_of_day end |
- (Object) end_of_minute
Return a DATE_TIME value representing the last second of the minute containing the receiver
68 69 70 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 68 def end_of_minute change(:sec => 59) end |
- (Object) end_of_month
Return a DATE_TIME value representing the last second of the month containing the receiver
108 109 110 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 108 def end_of_month change(:day => days_in_month, :hour => 23, :min => 59, :sec => 59) end |
- (Object) end_of_week_with_wkst(wkst)
Return a DATE_TIME value representing the last second of the ISO week starting with wkst containing the receiver
98 99 100 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 98 def end_of_week_with_wkst(wkst) date = at_start_of_week_with_wkst(wkst).advance(:days => 6).end_of_day end |
- (Object) end_of_year
Return a DATE_TIME value representing the last second of the month containing the receiver
118 119 120 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 118 def end_of_year change(:month => 12, :day => 31, :hour => 23, :min => 59, :sec => 59) end |
- (Object) in_month(month)
Return a DATE-TIME representing the same time, on the same day of the month in month. If the month of the receiver has more days than the target month the last day of the target month will be used.
152 153 154 155 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 152 def in_month(month) first = change(:day => 1, :month => month) first.change(:day => [first.days_in_month, day].min) end |
- (Boolean) in_week_starting?(date)
Return a DATE-TIME property representing the receiver on a different day (if necessary) so that the result is within the 7 days starting with date
51 52 53 54 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 51 def in_week_starting?(date) wkst_jd = date.jd @date_time_value.jd.between?(wkst_jd, wkst_jd + 6) end |
- (Object) start_of_day
Return a DATE_TIME value representing the first second of the day containing the receiver
83 84 85 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 83 def start_of_day change(:hour => 0, :min => 0, :sec => 0) end |
- (Object) start_of_hour
Return a DATE_TIME value representing the first second of the hour containing the receiver
73 74 75 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 73 def start_of_hour change(:min => 0, :sec => 0) end |
- (Object) start_of_minute
Return a DATE_TIME value representing the first second of the minute containing the receiver
63 64 65 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 63 def start_of_minute change(:sec => 0) end |
- (Object) start_of_month
Return a DATE_TIME value representing the first second of the month containing the receiver
103 104 105 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 103 def start_of_month change(:day => 1, :hour => 0, :min => 0, :sec => 0) end |
- (Object) start_of_week_with_wkst(wkst)
Return a Ruby Date representing the first day of the ISO week starting with wkst containing the receiver
93 94 95 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 93 def start_of_week_with_wkst(wkst) @date_time_value.start_of_week_with_wkst(wkst) end |
- (Object) start_of_year
Return a DATE_TIME value representing the first second of the month containing the receiver
113 114 115 |
# File 'lib/ri_cal/property_value/date_time/time_machine.rb', line 113 def start_of_year change(:month => 1, :day => 1, :hour => 0, :min => 0, :sec => 0) end |