Rename and validate utcoffset variable

This commit is contained in:
Saivann 2014-03-13 22:52:42 -04:00
parent 042cfff6fd
commit 9792c3b582

View file

@ -48,7 +48,7 @@ module Jekyll
next if !m.has_key?('event_url') or ( !m['event_url'].is_a?(String) and !m['event_url'].is_a?(Integer) and !m['event_url'].is_a?(Float) )
# Assign variables
time = m['time'].to_s
utfoffset = m['utc_offset'].to_s
utcoffset = m['utc_offset'].to_s
title = m['group']['name'].to_s
venue = m['venue']['name'].to_s
address = m['venue']['address_1'].to_s
@ -59,6 +59,7 @@ module Jekyll
lon = m['venue']['lon'].to_s
# Skip meetups with malformed data
next if !/^[0-9]{1,15}$/.match(time)
next if !/^-?[0-9]{1,10}$/.match(utcoffset)
next if !/^.{1,150}$/.match(title)
next if !/^.{1,150}$/.match(venue)
next if !/^.{1,150}$/.match(address)
@ -69,7 +70,7 @@ module Jekyll
next if !/^-?[0-9]{1,3}(\.[0-9]{1,15})?$/.match(lon) or ( lon.to_f < -180 and lon.to_f > 180 )
next if lon.to_f == 0 and lat.to_f == 0
# Format variables
time = Time.at((time.to_i + utfoffset.to_i) / 1000)
time = Time.at((time.to_i + utcoffset.to_i) / 1000)
time.utc
date = time.year.to_s + '-' + time.month.to_s.rjust(2,'0') + '-' + time.day.to_s.rjust(2,'0')
country = country.upcase