Skip to content

Instantly share code, notes, and snippets.

@hamannp
Created September 8, 2011 17:21
Show Gist options
  • Save hamannp/1203986 to your computer and use it in GitHub Desktop.
Save hamannp/1203986 to your computer and use it in GitHub Desktop.
def parse_date(date)
begin
if date_in_numeric_format? date
Time.new (date / 1e6).to_int
else
DateTime.parse date
end
rescue => e
puts e.to_s + " " + date.to_s + " class: " + date.class.to_s
end
end
def is_i? str
!!( str =~ /^[-+]?[0-9]+$/)
end
def date_in_numeric_format? date
return true if date.is_a?(Fixnum)
return true if date.is_a?(Integer)
return true if is_i?(date)
false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment