Module: Workpattern::Base

Included in:
Workpattern
Defined in:
lib/workpattern/utility/base.rb

Overview

Mixins expected to be used in more than one class

Since:

  • 0.2.0

Constant Summary collapse

@@tz =

Holds local timezone info

Since:

  • 0.2.0

nil

Instance Method Summary collapse

Instance Method Details

#timezoneObject

Retrieves the local timezone

Since:

  • 0.2.0



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

Since:

  • 0.2.0



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

Since:

  • 0.2.0



13
14
15
# File 'lib/workpattern/utility/base.rb', line 13

def to_utc(date)
  date.to_time.utc
end