This commit is contained in:
BoHung Chiu 2022-08-23 18:52:59 +08:00
parent 2ddc292255
commit 4b0e27a316
1 changed files with 7 additions and 7 deletions

View File

@ -95,20 +95,20 @@ class WritingConference
period_end_ym = [self.period_end_date.year, self.period_end_date.month] period_end_ym = [self.period_end_date.year, self.period_end_date.month]
same_year = period_start_ym[0] == period_end_ym[0] same_year = period_start_ym[0] == period_end_ym[0]
same_month = period_start_ym[1] == period_end_ym[1] same_month = period_start_ym[1] == period_end_ym[1]
month_date_format = date_format.sub('%Y','').gsub(',','').strip.sub(/^[\/\-\.]/,'').sub(/[\/\-\.]$/,'')
if same_year && same_month if same_year && same_month
date = self.period_start_date.strftime("#{month_date_format}-#{self.period_end_date.day}, %Y") date = self.period_start_date.strftime(date_format.sub('%d', "%d-#{self.period_end_date.day}"))
elsif same_year elsif same_year
date = self.period_start_date.strftime("#{month_date_format}-#{self.period_end_date.strftime(month_date_format)}, %Y") month_date_format = date_format.match(/(%m|%d)[\-\/\.]*(%m|%d)/)[0] rescue ''
date = self.period_start_date.strftime(date_format.sub(month_date_format, "#{month_date_format}-#{self.period_end_date.strftime(month_date_format)}"))
else else
date = self.period_start_date.strftime(date_format) + ' ~ ' + self.period_end_date.strftime(date_format) date = self.period_start_date.strftime(date_format) + ' ~ ' + self.period_end_date.strftime(date_format)
end end
end end
elsif period_start_date_present || period_end_date_present elsif period_start_date_present || period_end_date_present
if self.period_start_date if self.period_start_date
date = self.period_start_date.strftime('%b. %d, %Y') + ' ~ ' + I18n.t('personal_conference.up_to_today') date = self.period_start_date.strftime(date_format) + ' ~ ' + I18n.t('personal_conference.up_to_today')
else else
date = self.period_end_date.strftime('%b. %d, %Y') date = self.period_end_date.strftime(date_format)
end end
end end
date date
@ -160,7 +160,7 @@ class WritingConference
end end
fields_to_show = fields_to_show - fields_to_remove fields_to_show = fields_to_show - fields_to_remove
date_format = (I18n.locale == :zh_tw ? '%Y-%m-%d' : '%b. %d, %Y') date_format = (I18n.locale == :zh_tw ? '%Y/%m/%d' : '%b. %d, %Y')
plugin_datas = datas.sort_for_frontend.collect do |p| plugin_datas = datas.sort_for_frontend.collect do |p|
pd_data = [] pd_data = []
@ -234,7 +234,7 @@ class WritingConference
end end
value = value.join(" / ") value = value.join(" / ")
when "period" when "period"
value = self.duration((I18n.locale == :zh_tw ? '%Y-%m-%d' : '%b. %d, %Y')) value = self.duration((I18n.locale == :zh_tw ? '%Y/%m/%d' : '%b. %d, %Y'))
when "publication_date" when "publication_date"
get_setting get_setting
value = self.publication_date.strftime(@setting.publication_date_format) rescue "" value = self.publication_date.strftime(@setting.publication_date_format) rescue ""