Skip to content

Recordings dates with incorrect time zones  #2

@pavel-manylov

Description

@pavel-manylov

Example response from BBB (0.8) has this information:

<startTime>Mon Apr 09 17:40:55 YEKT 2012</startTime>

but :startTime param will have this value:

1.9.3-p0 :023 > t=$bigbluebutton_api.get_recordings(:meetingID=>meeting.id)[:recordings][0][:startTime]
 => Mon, 09 Apr 2012 17:40:55 +0000

I wrote small monkey patch for this issue:

module BigBlueButton
  class BigBlueButtonFormatter
    # converts a value in the @hash to DateTime
    def to_datetime(key)
      unless @hash.has_key?(key) and @hash[key]
        nil
      else
        # BBB >= 0.8 uses the unix epoch for all time related values
        # older versions use strings

        # a number but in a String class
        if (@hash[key].class == String && @hash[key].to_i.to_s == @hash[key])
          value = @hash[key].to_i
        else
          value = @hash[key]
        end

        if value.is_a?(Numeric)
          result = value == 0 ? nil : DateTime.parse(Time.at(value/1000.0).to_s)
        else
          if value.downcase == "null"
            result = nil
          else
            result = Time.parse(value).to_datetime #this line has been changed
          end
        end

        @hash[key] = result
      end
    end
  end  
end

And now:

1.9.3-p0 :002 > t=$bigbluebutton_api.get_recordings(:meetingID=>meeting.id)[:recordings][0][:startTime]
 => Mon, 09 Apr 2012 17:40:55 +0600

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions