Sha256: 1a2fce309425c446c388e3c8a059617c7bac2b122aafd32cdf1de58e93f024a8
Contents?: true
Size: 775 Bytes
Versions: 4
Compression:
Stored size: 775 Bytes
Contents
# frozen_string_literal: true module ConvenientService module Examples module Standard class DateTime module Services class SafeParse include ConvenientService::Standard::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 error( data: {exception: exception}, message: "Failed to parse `DateTime` object from `#{string}` with `#{format}`" ) end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems