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?


62
63
64
# File 'lib/football-timezones/timezones.rb', line 62

def initialize( zone )
  @zone = zone
end

Instance Method Details

#assert(cond, msg) ⇒ Object



90
91
92
93
94
95
96
97
# File 'lib/football-timezones/timezones.rb', line 90

def assert( cond, msg )
  if cond
    # do nothing

  else
    puts "!!! assert failed - #{msg}"
    exit 1
  end
end

#dst?Boolean

Returns:

  • (Boolean)


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

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

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



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

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



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

def name() @zone.name; end

#nowObject



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

def now() @zone.now; end

#to_local(time) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/football-timezones/timezones.rb', line 70

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