Sha256: af64d545c0f7b72392aaa901e1608436d902cbc2a79b55ab1b8f4a9d697212cd

Contents?: true

Size: 803 Bytes

Versions: 7

Compression:

Stored size: 803 Bytes

Contents

module SoberSwag
  module Reporting
    module Input
      module Converting
        ##
        # Convert via a date.
        #
        # Note: unlike the swagger spec, we first try to convert
        # rfc8601, then try rfc3339.
        Date = (
          SoberSwag::Reporting::Input::Text
               .new
               .mapped { |str|
            begin
              ::Date.rfc3339(str)
            rescue ArgumentError
              Report::Value.new(['was not an RFC 3339 date string'])
            end
          } |
          SoberSwag::Reporting::Input::Text
            .new
            .mapped do |str|
            ::Date.iso8601(str)
          rescue ArgumentError
            Report::Value.new(['was not an ISO8601 date string'])
          end).format('date')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sober_swag-0.25.2 lib/sober_swag/reporting/input/converting/date.rb
sober_swag-0.25.1 lib/sober_swag/reporting/input/converting/date.rb
sober_swag-0.25.0 lib/sober_swag/reporting/input/converting/date.rb
sober_swag-0.24.1 lib/sober_swag/reporting/input/converting/date.rb
sober_swag-0.24.0 lib/sober_swag/reporting/input/converting/date.rb
sober_swag-0.23.0 lib/sober_swag/reporting/input/converting/date.rb
sober_swag-0.22.0 lib/sober_swag/reporting/input/converting/date.rb