From 4b0e27a31627445c82d20174dfa5948cf0ff4740 Mon Sep 17 00:00:00 2001 From: bohung Date: Tue, 23 Aug 2022 18:52:59 +0800 Subject: [PATCH] Fix bug. --- app/models/writing_conference.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/writing_conference.rb b/app/models/writing_conference.rb index 18d7661..18ce8af 100644 --- a/app/models/writing_conference.rb +++ b/app/models/writing_conference.rb @@ -95,20 +95,20 @@ class WritingConference period_end_ym = [self.period_end_date.year, self.period_end_date.month] same_year = period_start_ym[0] == period_end_ym[0] 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 - 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 - 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 date = self.period_start_date.strftime(date_format) + ' ~ ' + self.period_end_date.strftime(date_format) end end elsif period_start_date_present || period_end_date_present 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 - date = self.period_end_date.strftime('%b. %d, %Y') + date = self.period_end_date.strftime(date_format) end end date @@ -160,7 +160,7 @@ class WritingConference end 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| pd_data = [] @@ -234,7 +234,7 @@ class WritingConference end value = value.join(" / ") 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" get_setting value = self.publication_date.strftime(@setting.publication_date_format) rescue ""