Module: CET

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

Overview

check - nest CET class inside UTC e.g. UTC::CET - why? why not?

make UTC and CET into a module (not class) - why? why not?

Class Method Summary collapse

Class Method Details

.nowObject

central european time helpers



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

def self.now()  zone.now; end

.strptime(str, format) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/football-timezones/timezones.rb', line 8

def self.strptime( str, format )

  ### fix - change to Time.strptime - why? why not?
  ##       (simply) ignore offset; double check that hours, minutes
  ##        get parsed as is (without applying offset)

  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 - CET parse date; DateTime returns offset != +0:00"
      pp d.zone
      pp d
      exit 1
   end

###  2006-03-26 02:00:00
##  raise exception
##    is an invalid local time. (TZInfo::PeriodNotFound)
  ## quick fix add +1
##  2012-03-25 02:00:00
##   is an invalid local time. (TZInfo::PeriodNotFound)

   if ['2018-03-25 02:00',
       '2012-03-25 02:00',
       '2006-03-26 02:00',
      ].include?( d.strftime( '%Y-%m-%d %H:%M' ))
     puts "!! hack - fix CET date #{d} - add +1 hour"
     pp d
     zone.local_time( d.year, d.month, d.day, d.hour+1, d.min, d.sec )
   else
     zone.local_time( d.year, d.month, d.day, d.hour, d.min, d.sec )
   end
end

.todayObject



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

def self.today() now.to_date; end

.zoneObject



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

def self.zone() @zone ||= UTC.find_zone( 'Europe/Vienna' ); end