Class: DateFormat::DateExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/docfolio/date_format.rb

Overview

Extracts a date in seconds past UNIX epoc from a string date. The result can be used for other date operations. Converts from dd-mmm-yy and similar formats as commonly found in csv files

Instance Method Summary collapse

Instance Method Details

#format_date(date) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/docfolio/date_format.rb', line 8

def format_date(date)
  day, month, year = components(date)
  begin
    Time.new(year, month, day).to_i
  rescue ArgumentError => e
    print_argument_error_msg(e)
    return nil
  rescue => e
    raise e
  end
end