Module: Appoxy::TimeStuff::Zones
- Defined in:
- lib/ui/time_zoner.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
:nodoc:
6 7 8 9 10 11 12 |
# File 'lib/ui/time_zoner.rb', line 6 def self.included(base) #:nodoc: base.class_eval do #puts 'TP mixing' # If we want to_s to ALWAYS be local, uncomment the below line #alias_method :to_s, :to_local_s # end end |
Instance Method Details
#to_local_s(user = nil, options = {}) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/ui/time_zoner.rb', line 28 def to_local_s(user = nil, ={}) format = [:format] || :long #puts 'calling to_local_s on ' + self.class.name zone = to_user_time(user) return zone.to_formatted_s(format) end |
#to_pst ⇒ Object
14 15 16 |
# File 'lib/ui/time_zoner.rb', line 14 def to_pst return in_time_zone('Pacific Time (US & Canada)') end |
#to_user_time(user = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/ui/time_zoner.rb', line 18 def to_user_time(user = nil) local = nil if user && user.time_zone local = in_time_zone(user.time_zone) else local = to_pst end local end |