From 6bdd45e7b7681a341008aa79fc70313af1642b71 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Tue, 24 Mar 2020 17:45:09 +0100 Subject: [PATCH] Fix timezone when import datetime --- app/models/repository_date_time_value.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/repository_date_time_value.rb b/app/models/repository_date_time_value.rb index 9a7402190..ad1619e91 100644 --- a/app/models/repository_date_time_value.rb +++ b/app/models/repository_date_time_value.rb @@ -24,7 +24,8 @@ class RepositoryDateTimeValue < RepositoryDateTimeValueBase def self.import_from_text(text, attributes, options = {}) date_format = (options.dig(:user, :settings, :date_format) || Constants::DEFAULT_DATE_FORMAT).gsub(/%-/, '%') + ' %H:%M' - new(attributes.merge(data: DateTime.strptime(text, date_format))) + Time.zone = options.dig(:user, :settings, :time_zone) || 'UTC' + new(attributes.merge(data: Time.zone.strptime(text, date_format))) rescue ArgumentError nil end