DateTime.parse => Time.zone.parse
This commit is contained in:
parent
2238e5bd9f
commit
f620e4aee2
11 changed files with 19 additions and 19 deletions
|
@ -24,7 +24,7 @@ class ChampDecorator < Draper::Decorator
|
|||
if type_champ == TypeDeChamp.type_champs.fetch(:date)
|
||||
object.value
|
||||
elsif type_champ == TypeDeChamp.type_champs.fetch(:datetime) && object.value != ' 00:00'
|
||||
DateTime.parse(object.value, "%Y-%m-%d %H:%M").strftime("%Y-%m-%d")
|
||||
Time.zone.parse(object.value, "%Y-%m-%d %H:%M").strftime("%Y-%m-%d")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ class Champs::DatetimeChamp < Champ
|
|||
nil
|
||||
end
|
||||
elsif /^\d{2}\/\d{2}\/\d{4}\s\d{2}:\d{2}$/.match?(value) # old browsers can send with dd/mm/yyyy hh:mm format
|
||||
self.value = DateTime.parse(value, "%d/%m/%Y %H:%M").strftime("%Y-%m-%d %H:%M")
|
||||
self.value = Time.zone.parse(value, "%d/%m/%Y %H:%M").strftime("%Y-%m-%d %H:%M")
|
||||
elsif !(/^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}$/.match?(value)) # a datetime not correctly formatted should not be stored
|
||||
self.value = nil
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- parsed_value = champ.value.present? ? DateTime.parse(champ.value) : Time.zone.now
|
||||
- parsed_value = champ.value.present? ? Time.zone.parse(champ.value) : Time.zone.now
|
||||
|
||||
.datetime
|
||||
= form.datetime_select(:value, selected: parsed_value, start_year: 1950, end_year: 2100, minute_step: 5)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue