feat: Support two date formats: ISO 8601 and the standard US date format

used in google sheets
This commit is contained in:
Nelson Jovel 2024-02-27 11:55:47 -08:00
parent 03349b0ed5
commit d6735d449d
6 changed files with 45 additions and 23 deletions

View file

@ -48,13 +48,11 @@ class SurveyItemValues
def recorded_date
@recorded_date ||= begin
recorded_date = value_from(pattern: /Recorded\s*Date/i)
puts recorded_date
date = nil
begin
date = Date.parse(recorded_date)
rescue StandardError => e
date = Date.strptime(recorded_date, "%m/%d/%Y")
end
date = if recorded_date.include?("T")
Date.parse(recorded_date)
else
Date.strptime(recorded_date, "%m/%d/%Y")
end
end
end