Sha256: a8bd797b922865a2a4ab3a1164d29c53a213a93b47183af6a3f7bd072dfcad05

Contents?: true

Size: 572 Bytes

Versions: 35

Compression:

Stored size: 572 Bytes

Contents

# frozen_string_literal: true

module ActiveJob
  module Serializers
    class TimeWithZoneSerializer < ObjectSerializer # :nodoc:
      NANO_PRECISION = 9

      def serialize(time_with_zone)
        super(
          "value" => time_with_zone.iso8601(NANO_PRECISION),
          "time_zone" => time_with_zone.time_zone.tzinfo.name
        )
      end

      def deserialize(hash)
        Time.iso8601(hash["value"]).in_time_zone(hash["time_zone"] || Time.zone)
      end

      private
        def klass
          ActiveSupport::TimeWithZone
        end
    end
  end
end

Version data entries

35 entries across 35 versions & 5 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/activejob-7.1.3.4/lib/active_job/serializers/time_with_zone_serializer.rb
activejob-8.0.1 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-8.0.0.1 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-7.2.2.1 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-7.1.5.1 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-8.0.0 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-7.2.2 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-7.1.5 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-8.0.0.rc2 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-7.2.1.2 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-7.1.4.2 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-8.0.0.rc1 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-7.2.1.1 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-7.1.4.1 lib/active_job/serializers/time_with_zone_serializer.rb
activejob-8.0.0.beta1 lib/active_job/serializers/time_with_zone_serializer.rb
omg-activejob-8.0.0.alpha9 lib/active_job/serializers/time_with_zone_serializer.rb
omg-activejob-8.0.0.alpha8 lib/active_job/serializers/time_with_zone_serializer.rb
omg-activejob-8.0.0.alpha7 lib/active_job/serializers/time_with_zone_serializer.rb
omg-activejob-8.0.0.alpha4 lib/active_job/serializers/time_with_zone_serializer.rb
omg-activejob-8.0.0.alpha3 lib/active_job/serializers/time_with_zone_serializer.rb