seminar2_old/app/helpers/admin/seminars_values_helper.rb

109 lines
2.8 KiB
Ruby

module Admin::SeminarsValuesHelper
def show_west_calender(from_to=nil)
case from_to
when :to
date = get_date(:to)
when :from
date = get_date(:from)
when nil
date = get_date
end
# case self.member_profile_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(from_to=nil)
get_minguo
case from_to
when :to
date = get_date(:to)
when :from
date = get_date(:from)
when nil
date = get_date
end
@date = date.split('/')
date_year = @date[0].to_i
year_str = ""
unless date_year == 1912
m_year = (date_year - 1912).abs.to_s + I18n.t("date.minguo_calendar.year")
year_str = minguo_format_year(m_year)
end
get_minguo_year(from_to) + minguo_m_y_d_time(from_to)
end
def get_minguo_year(from_to=nil)
case from_to
when :to
date = get_date(:to)
when :from
date = get_date(:from)
when nil
date = get_date
end
@date = date.split('/')
date_year = @date[0].to_i
m_year = (date_year - 1911).abs
year_end = I18n.t("date.minguo_calendar.year")
case
when date_year <1912
I18n.t("date.minguo_calendar.before") + (m_year+1).to_s + year_end
when date_year ==1912
I18n.t("date.minguo_calendar.first_year")
when date_year >1912
I18n.t("date.minguo_calendar.after")+ (m_year).to_s + year_end
end # of case tw_calendar year
end
def minguo_m_y_d_time(from_to=nil)
case from_to
when :to
date = get_date(:to)
when :from
date = get_date(:from)
when nil
date = get_date
end
@date = date.split('/')
case self.seminar_signup_field["typeC"]["format"]
when 'format1' # Y/M/D h:m
"/#{@date[1]}/#{@date[2]}"
when 'format2' # Y/M/D
"/#{@date[1]}/#{@date[2]}"
when 'format3' # Y/M
"/#{@date[1]}#{I18n.t("date.minguo_calendar.month")}"\
when 'format4' # Y
''
end # of case
end
def get_date_by_format(from_to = nil)
case I18n.locale
when :zh_tw
case
when self.seminar_signup_field["typeC"]["calendar"] == "west_calendar"
show_west_calender(from_to)
when self.seminar_signup_field["typeC"]["calendar"] == "tw_calendar"
show_minguo_calendar(from_to)
end #case self.seminar_signup_field["typeC"]["calendar"]
when :en
show_west_calender(from_to)
end
end
end