• Register

ACTIVE Network API Forums

Activity Search API v2

RSS Feed

Working With Dates

    • rouleurmedia
    • Topic created 11 years ago

    I'm having some issues parsing dates from the V2 feed. There seems to be inconsistent data. I'm trying to work with the timezone offset to convert the UTC times in the feed. Any advice for how to convert the start and end dates in a consistent way. This is some ruby code with some of the hacks to get dates that will work for me.

    dst = event["place"]["timezoneDST"].present? ? event["place"]["timezoneDST"] : 0
    tz_offset = event["place"]["timezoneOffset"].present? ? event["place"]["timezoneOffset"] : 0
    offset = tz_offset + dst
    puts offset
    
    puts event["activityStartDate"].slice(11,8)
    if event["activityStartDate"].slice(11,8) == "00:00:00"
      offset = 0
    end
    puts offset
    if offset < 0
      offset_num = "-" + ("%02d" % (offset * -1)) + ":00"
    else
      offset_num = "+" + ("%02d" % (offset * -1)) + ":00"
    end
    puts offset_num
    puts "#{event["activityStartDate"]}#{offset_num}"
    starts_at = DateTime.strptime("#{event["activityStartDate"]} #{offset_num}", "%Y-%m-%dT%H:%M:%S %z")+(offset).hours   
    puts starts_at
    puts "#{event["activityEndDate"]}"
    ends_at = DateTime.strptime("#{event["activityEndDate"]} #{offset_num}", "%Y-%m-%dT%H:%M:%S %z")+(offset).hours
    puts ends_at
    

    Is doesn't appear that all events have the timezoneOffset field, or if they do some of the times are not UTC, and some are. I've have to do some hacks to get consistent data.

    Message edited by rouleurmedia 11 years ago

    Tags

[ Page 1 of 1 ]