1
12 34
The script:
#!/usr/bin/env ruby
require 'rubygems'
require 'geonames'
lat=-54.936772
lon=-67.604408
timezone = Geonames::WebService.timezone lat, lon
dst_offset = timezone.dst_offset.to_i # Is this for the day it's done?
FIX to_i is not ROBUST
gmt_offset = timezone.gmt_offset.to_i # not affected by DST
timezone_id = timezone.timezone_id # Wordy version of timezone
puts "timezone_id: #{timezone_id} \ngmt_offset: #{gmt_offset}
\ndst_offset: #{dst_offset}"
places_nearby = Geonames::WebService.find_nearby_place_name lat, lon
location = "#{places_nearby.first.name},
#{places_nearby.first.country_name}"
puts "location: #{location}"
# Result
# timezone_id: America/Santiago
# gmt_offset: -3
# dst_offset: -4
# location: Puerto Williams, Chile
Am I mixed up or is the answer backwards?
Here in California GMT-8 and DST is -7. Santiago should be on standard
time now, not that that's relevant to what I think should be being
delivered.
#!/usr/bin/env ruby
require 'rubygems'
require 'geonames'
lat=-54.936772
lon=-67.604408
timezone = Geonames::WebService.timezone lat, lon
dst_offset = timezone.dst_offset.to_i # Is this for the day it's done?
FIX to_i is not ROBUST
gmt_offset = timezone.gmt_offset.to_i # not affected by DST
timezone_id = timezone.timezone_id # Wordy version of timezone
puts "timezone_id: #{timezone_id} \ngmt_offset: #{gmt_offset}
\ndst_offset: #{dst_offset}"
places_nearby = Geonames::WebService.find_nearby_place_name lat, lon
location = "#{places_nearby.first.name},
#{places_nearby.first.country_name}"
puts "location: #{location}"
# Result
# timezone_id: America/Santiago
# gmt_offset: -3
# dst_offset: -4
# location: Puerto Williams, Chile
Am I mixed up or is the answer backwards?
Here in California GMT-8 and DST is -7. Santiago should be on standard
time now, not that that's relevant to what I think should be being
delivered.