Sha256: 6d85901bb9e61c787e114a3bb8734b86a8a4033d32cb452b897753085eaaa76b

Contents?: true

Size: 733 Bytes

Versions: 7

Compression:

Stored size: 733 Bytes

Contents

module SoberSwag
  module Reporting
    module Input
      module Converting
        ##
        # Convert via a date.
        DateTime =
          SoberSwag::Reporting::Input::Text
          .new
          .mapped { |str|
            begin
              ::DateTime.rfc3339(str)
            rescue ArgumentError
              Report::Value.new(['was not an RFC 3339 date-time string'])
            end
          }.or(
            SoberSwag::Reporting::Input::Text
              .new
              .mapped do |str|
              ::DateTime.iso8601(str)
            rescue ArgumentError
              Report::Value.new(['was not an ISO8601 date-time string'])
            end
          ).format('date-time')
      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_time.rb
sober_swag-0.25.1 lib/sober_swag/reporting/input/converting/date_time.rb
sober_swag-0.25.0 lib/sober_swag/reporting/input/converting/date_time.rb
sober_swag-0.24.1 lib/sober_swag/reporting/input/converting/date_time.rb
sober_swag-0.24.0 lib/sober_swag/reporting/input/converting/date_time.rb
sober_swag-0.23.0 lib/sober_swag/reporting/input/converting/date_time.rb
sober_swag-0.22.0 lib/sober_swag/reporting/input/converting/date_time.rb