Sha256: 330705bf2243bf5a5d1cdbefa72ddbf193c41e05f65e0b99e0b2e589904c5d12

Contents?: true

Size: 672 Bytes

Versions: 3

Compression:

Stored size: 672 Bytes

Contents

require 'time_zone_hack'

module FacebookGoogleCalendarSync

  module Timezone

    def with_timezone target, timezone
      TimeZoneProxy.new(target, timezone)
    end

    class TimeZoneProxy < BasicObject
      def initialize target, timezone
        @target = target
        @timezone = timezone
      end

      def method_missing(method, *args, &block)
        result = @target.send(method, *args, &block)
        convert_timezone_if_date(result)
      end

      def convert_timezone_if_date result
        if result.respond_to?(:convert_time_zone)
          result.convert_time_zone(@timezone)
        else
          result
        end
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facebook-google-calendar-sync-0.2.2 lib/facebook_google_calendar_sync/timezone.rb
facebook-google-calendar-sync-0.2.1 lib/facebook_google_calendar_sync/timezone.rb
facebook-google-calendar-sync-0.2.0 lib/facebook_google_calendar_sync/timezone.rb