Sha256: a27c3cc50a0bcf781767e6307864920f9873d3f9f7c81bd0bf31e43c043567d9

Contents?: true

Size: 933 Bytes

Versions: 29

Compression:

Stored size: 933 Bytes

Contents

module AchClient
  class AchWorks
    ##
    # For formatting dates for AchWorks
    class DateFormatter

      ##
      # Formats given date in the manner required by AchWorks
      # The date can be a String or a Date/DateTime.
      # If it is a string it will be given to the DateTime parser
      # Will be formatted like 2016-08-11T09:56:24.35103-04:00
      # @param date [Object] String or Date to format
      # @return [String] formatted datetime
      def self.format(date)
        if date.is_a?(String)
          format_string(date)
        elsif date.respond_to?(:strftime)
          format_date(date)
        else
          raise 'Cannot format date'
        end
      end

      private_class_method def self.format_string(string)
        format_date(DateTime.parse(string))
      end

      private_class_method def self.format_date(date)
        date.strftime('%Y-%m-%dT%H:%M:%S.%5N%:z')
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
ach_client-5.3.3 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-5.3.2 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-5.3.1 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-5.3.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-5.2.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-5.1.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-5.0.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-4.0.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-3.1.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-3.0.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-2.1.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-2.0.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-1.1.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-1.0.3 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-1.0.2 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-1.0.1 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-1.0.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-0.7.0 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-0.6.8 lib/ach_client/providers/soap/ach_works/date_formatter.rb
ach_client-0.6.7 lib/ach_client/providers/soap/ach_works/date_formatter.rb