Merge pull request #2487 from aignatov-bio/ai-sci-4464-fix-timezone-when-import-datetime

Fix timezone when import datetime [SCI-4464]
This commit is contained in:
Miha Mencin 2020-03-24 19:42:48 +01:00 committed by GitHub
commit 89e4a73fbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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