Module: UTC
- Defined in:
- lib/football-timezones/timezones.rb
Defined Under Namespace
Classes: Timezone
Class Method Summary collapse
- .find_zone(name) ⇒ Object
- .now ⇒ Object
-
.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 ???.
- .today ⇒ Object
Class Method Details
.find_zone(name) ⇒ Object
53 54 55 56 57 |
# File 'lib/football-timezones/timezones.rb', line 53 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 |
.now ⇒ Object
30 |
# File 'lib/football-timezones/timezones.rb', line 30 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 ???
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/football-timezones/timezones.rb', line 39 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 |
.today ⇒ Object
31 |
# File 'lib/football-timezones/timezones.rb', line 31 def self.today() now.to_date; end |