Module: Workpattern::Base
- Included in:
- Workpattern
- Defined in:
- lib/workpattern/utility/base.rb
Overview
Mixins expected to be used in more than one class
Constant Summary collapse
- @@tz =
Holds local timezone info
nil
Instance Method Summary collapse
-
#timezone ⇒ Object
Retrieves the local timezone.
-
#to_local(date) ⇒ Object
Converts a date like object into local time.
-
#to_utc(date) ⇒ Object
Converts a date like object into utc.
Instance Method Details
#timezone ⇒ Object
Retrieves the local timezone
23 24 25 |
# File 'lib/workpattern/utility/base.rb', line 23 def timezone @@tz || @@tz = TZInfo::Timezone.get(Time.now.zone) end |
#to_local(date) ⇒ Object
Converts a date like object into local time
18 19 20 |
# File 'lib/workpattern/utility/base.rb', line 18 def to_local(date) date.to_time.getgm end |
#to_utc(date) ⇒ Object
Converts a date like object into utc
13 14 15 |
# File 'lib/workpattern/utility/base.rb', line 13 def to_utc(date) date.to_time.utc end |