68 lines
2.0 KiB
Ruby
68 lines
2.0 KiB
Ruby
|
module AttributeValuesHelper
|
||
|
def show_west_calender
|
||
|
date = get_date
|
||
|
case self.attribute_field["typeC"]["format"]
|
||
|
when 'format1' # Y/M/D h:m
|
||
|
date.strftime("%Y/%m/%d %H:%M")
|
||
|
when 'format2' # Y/M/D
|
||
|
date.strftime("%Y/%m/%d")
|
||
|
when 'format3' # Y/M
|
||
|
date.strftime("%Y/%m")
|
||
|
when 'format4' # Y
|
||
|
date.strftime("%Y")
|
||
|
end # of case west cal format
|
||
|
end
|
||
|
|
||
|
def show_minguo_calendar
|
||
|
get_minguo
|
||
|
date = get_date
|
||
|
year_str = ""
|
||
|
unless date.year == 1912
|
||
|
m_year = (date.year - 1912).abs.to_s + I18n.t("admin.infos.date.minguo_calendar.year")
|
||
|
year_str = minguo_format_year(m_year)
|
||
|
end
|
||
|
get_minguo_year + minguo_m_y_d_time
|
||
|
end
|
||
|
|
||
|
def get_minguo_year
|
||
|
date = get_date
|
||
|
m_year = (date.year - 1911).abs
|
||
|
year_end = I18n.t("admin.infos.date.minguo_calendar.year")
|
||
|
case
|
||
|
when date.year <1912
|
||
|
I18n.t("admin.infos.date.minguo_calendar.before") + (m_year+1).to_s + year_end
|
||
|
when date.year ==1912
|
||
|
I18n.t("admin.infos.date.minguo_calendar.first_year")
|
||
|
when date.year >1912
|
||
|
I18n.t("admin.infos.date.minguo_calendar.after")+ (m_year).to_s + year_end
|
||
|
end # of case tw_claendar year
|
||
|
end
|
||
|
|
||
|
def minguo_m_y_d_time
|
||
|
date = get_date
|
||
|
case self.attribute_field["typeC"]["format"]
|
||
|
when 'format1' # Y/M/D h:m
|
||
|
date.strftime(" %m/%d %H:%M")
|
||
|
when 'format2' # Y/M/D
|
||
|
date.strftime(" %m/%d")
|
||
|
when 'format3' # Y/M
|
||
|
date.strftime(" %m#{I18n.t("admin.infos.date.minguo_calendar.month")}")
|
||
|
when 'format4' # Y
|
||
|
''
|
||
|
end # of case
|
||
|
end
|
||
|
|
||
|
def get_date_by_format
|
||
|
case I18n.locale
|
||
|
when :zh_tw
|
||
|
case
|
||
|
when self.attribute_field["typeC"]["claendar"] == "west_claendar"
|
||
|
show_west_calender
|
||
|
when self.attribute_field["typeC"]["claendar"] == "tw_claendar"
|
||
|
show_minguo_calendar
|
||
|
end #case self.attribute_field["typeC"]["claendar"]
|
||
|
when :en
|
||
|
show_west_calender
|
||
|
end
|
||
|
end
|
||
|
end
|