Changeset 9208 for trunk/activesupport/lib/active_support/time_with_zone.rb
- Timestamp:
- 04/02/08 06:56:44 (1 month ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/lib/active_support/time_with_zone.rb
r9149 r9208 145 145 end 146 146 147 %w(asctime day hour min mon sec wday yday year to_date).each do |name|148 define_method(name) do149 time.__send__(name)150 end151 end152 alias_method :ctime, :asctime153 alias_method :mday, :day154 alias_method :month, :mon155 156 147 def usec 157 148 time.respond_to?(:usec) ? time.usec : 0 158 149 end 159 160 %w(sunday? monday? tuesday? wednesday? thursday? friday? saturday?).each do |name|161 define_method(name) do162 time.__send__(name)163 end164 end unless RUBY_VERSION < '1.9'165 150 166 151 def to_a … … 220 205 # Send the missing method to time instance, and wrap result in a new TimeWithZone with the existing time_zone 221 206 def method_missing(sym, *args, &block) 222 result = utc.__send__(sym, *args, &block) 223 result = result.in_time_zone(time_zone) if result.acts_like?(:time) 224 result 207 if %w(+ - since ago advance).include?(sym.to_s) 208 result = utc.__send__(sym, *args, &block) 209 result.acts_like?(:time) ? result.in_time_zone(time_zone) : result 210 else 211 result = time.__send__(sym, *args, &block) 212 result.acts_like?(:time) ? self.class.new(nil, time_zone, result) : result 213 end 225 214 end 226 215