Sha256: 6548ffcd3987e6b3cfce03343595ae1ec4e38908d1db85e54b39e4b44d9988f0
Contents?: true
Size: 847 Bytes
Versions: 4
Compression:
Stored size: 847 Bytes
Contents
# frozen_string_literal: true module ConvenientService module Examples module Standard module V1 class DateTime module Services class SafeParse include ConvenientService::Standard::V1::Config attr_reader :string, :format def initialize(string:, format:) @string = string @format = format end def result success(date_time: ::DateTime.strptime(string, format)) rescue ::Date::Error => exception failure( data: {exception: exception}, message: "Failed to parse `DateTime` object from `#{string}` with `#{format}`" ) end end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems