Sha256: 24f28991b9ae98e89fbf07978488d11779680907a874d0df6be70678c3a9a305

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

# 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

6 entries across 6 versions & 1 rubygems

Version Path
workato-connector-sdk-1.0.1 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-1.0.0 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-0.5.0 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-0.4.1 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-0.4.0 lib/workato/connector/sdk/schema/type/time.rb
workato-connector-sdk-0.3.0 lib/workato/connector/sdk/schema/type/time.rb