Rename timezone attribute and add it to local date details field

This commit is contained in:
Vinoth Kannan
2018-10-16 05:04:55 +05:30
parent 8d06731484
commit 2c8c1bf188
5 changed files with 16 additions and 14 deletions

View File

@ -27,9 +27,10 @@ after_initialize do
dates = doc.css('span.discourse-local-date').map do |cooked_date|
date = {}
cooked_date.attributes.values.each do |attribute|
if attribute.name && ['data-date', 'data-time'].include?(attribute.name)
data_name = attribute.name&.gsub('data-', '')
if data_name && ['date', 'time', 'timezone'].include?(data_name)
unless attribute.value == 'undefined'
date[attribute.name.gsub('data-', '')] = CGI.escapeHTML(attribute.value || "")
date[data_name] = CGI.escapeHTML(attribute.value || "")
end
end
end