Parcourir la Source

Parse dates with Date.parse for format detection

Maarten van den Berg il y a 6 ans
Parent
commit
fe0f4511db
1 fichiers modifiés avec 4 ajouts et 4 suppressions
  1. 4 4
      app/models/activity.rb

+ 4 - 4
app/models/activity.rb

@@ -174,24 +174,24 @@ class Activity < ApplicationRecord
174 174
       a.description = row['description']
175 175
       a.location    = row['location']
176 176
 
177
-      sd            = Date.strptime(row['start_date'])
177
+      sd            = Date.parse row['start_date']
178 178
       st            = Time.strptime(row['start_time'], '%H:%M')
179 179
       a.start       = Time.zone.local(sd.year, sd.month, sd.day, st.hour, st.min)
180 180
 
181 181
       if row['end_date'].present?
182
-        ed          = Date.strptime(row['end_date'])
182
+        ed          = Date.parse row['end_date']
183 183
         et          = Time.strptime(row['end_time'], '%H:%M')
184 184
         a.end       = Time.zone.local(ed.year, ed.month, ed.day, et.hour, et.min)
185 185
       end
186 186
 
187 187
       if row['deadline_date'].present?
188
-        dd            = Date.strptime(row['deadline_date'])
188
+        dd            = Date.parse row['deadline_date']
189 189
         dt            = Time.strptime(row['deadline_time'], '%H:%M')
190 190
         a.deadline    = Time.zone.local(dd.year, dd.month, dd.day, dt.hour, dt.min)
191 191
       end
192 192
 
193 193
       if row['reminder_at_date'].present?
194
-        rd            = Date.strptime(row['reminder_at_date'])
194
+        rd            = Date.parse row['reminder_at_date']
195 195
         rt            = Time.strptime(row['reminder_at_time'], '%H:%M')
196 196
         a.reminder_at = Time.zone.local(rd.year, rd.month, rd.day, rt.hour, rt.min)
197 197
       end