Class: UTC::Timezone

Inherits:
Object
  • Object
show all
Defined in:
lib/football-timezones/timezones.rb

Overview

nested inside UTC

Instance Method Summary collapse

Constructor Details

#initialize(zone) ⇒ Timezone

todo/fix

cache timezone - why? why not?


79
80
81
# File 'lib/football-timezones/timezones.rb', line 79

def initialize( zone )
  @zone = zone
end

Instance Method Details

#assert(cond, msg) ⇒ Object



107
108
109
110
111
112
113
114
# File 'lib/football-timezones/timezones.rb', line 107

def assert( cond, msg )
  if cond
    # do nothing
  else
    puts "!!! assert failed - #{msg}"
    exit 1
  end
end

#dst?Boolean

Returns:

  • (Boolean)


84
# File 'lib/football-timezones/timezones.rb', line 84

def dst?() @zone.dst?; end

#local_time(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0) ⇒ Object



96
97
98
99
100
# File 'lib/football-timezones/timezones.rb', line 96

def local_time( year, month=1, mday=1, hour=0, min=0, sec=0 )
 ## add auto-fix for ambigious time (dst vs non-dst)
 ##    always select first for now (that is, dst)
   @zone.local_time( year, month, mday, hour, min, sec ) {|time| time.first }
end

#nameObject



83
# File 'lib/football-timezones/timezones.rb', line 83

def name() @zone.name; end

#nowObject



102
# File 'lib/football-timezones/timezones.rb', line 102

def now() @zone.now; end

#to_local(time) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/football-timezones/timezones.rb', line 87

def to_local( time )
   ## assert time is Time (not Date or DateTIme)
   ##  and assert utc!!!
   assert( time.is_a?( Time ),  "time #{time} is NOT of class Time; got #{time.class.name}" )
   assert( time.utc?,           "time #{time} is NOT utc; utc? returns #{time.utc?}" )
   local = @zone.to_local( time )
   local
end