Sha256: cd18452ccb2cceeb34c9eb49f0584da349a46b2ff78721b998cab7a69db67ea6

Contents?: true

Size: 1.15 KB

Versions: 15

Compression:

Stored size: 1.15 KB

Contents

# typed: true
# frozen_string_literal: true

require 'time'

module Workato
  module Connector
    module Sdk
      class Schema
        module Type
          class Time < ::Time
            PRECISION = 6

            def to_s(*args)
              if args.present?
                super
              else
                xmlschema(PRECISION)
              end
            end

            def self.from_time(value)
              new(
                value.year,
                value.month,
                value.day,
                value.hour,
                value.min,
                value.sec + Rational(value.nsec, 1_000_000_000),
                value.utc_offset
              )
            end

            def self.from_date_time(value)
              new(
                value.year,
                value.month,
                value.day,
                value.hour,
                value.min,
                value.sec + Rational(value.nsec, 1_000_000_000),
                value.zone
              )
            end

            def self.xmlschema(str)
              from_time(super(str))
            end
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
workato-connector-sdk-1.3.10 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.3.9 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.3.8 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.3.7 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.3.6 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.3.5 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.3.4 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.3.3 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.3.2 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.3.1 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.3.0 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.2.0 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.0.3 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.1.0 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.0.2 lib/workato/connector/sdk/schema/type/time.rb