Module: UTC

Defined in:
lib/football-timezones/timezones.rb

Defined Under Namespace

Classes: Timezone

Class Method Summary collapse

Class Method Details

.find_zone(name) ⇒ Object



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

def self.find_zone( name )
   zone = TZInfo::Timezone.get( name )
   ## wrap tzinfo timezone in our own - for adding more (auto)checks etc.
   zone ? Timezone.new( zone ) : nil
end

.nowObject



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

def self.now()  Time.now.utc; end

.strptime(str, format) ⇒ Object

– todo - make sure / assert it’s always utc - how??? utc = ## tz_utc.strptime( m, ‘%Y-%m-%dT%H:%M:%SZ’ )

note:  DateTime.strptime  is supposed to be unaware of timezones!!!
          use to parse utc

quick hack -

use to_time.getutc instead of utc ???


56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/football-timezones/timezones.rb', line 56

def self.strptime( str, format )
    d = DateTime.strptime( str, format )
    ## remove assert check - why? why not?
    if d.zone != '+00:00'    ### use d.offset != Ration(0,1)  - why? why not?
       puts "!! ASSERT - UTC parse date; DateTime returns offset != +0:00"
       pp d.zone
       pp d
       exit 1
    end
    ## note - ignores offset if any !!!!
    ##    todo/check - report warn if offset different from 0:00 (0/1) - why? why not?
    Time.utc( d.year, d.month, d.day, d.hour, d.min, d.sec )
end

.todayObject



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

def self.today() now.to_date; end