date - rails 4 date_select helper custom Thai calendar -
i'm using rails 4 create application. , in form use date_select helper user select birth date. can change months name thai no problem. wondering if there way display years according thai calendar 543 years more christian calendar. example if year 2015 thai year 2015+543 = 2558 , if year 1991 thai year 1991+543=2534. please want know if can done :). thanks.
you can use rails built in i18n support. create locale file thai language config/locales/th.rb
, override default date format. if have th.yml
file you'll have convert ruby hash , rename file th.rb
work:
{ th: { date: { formats: { default: lambda { |date, _| "%d.%m.#{date.year + 543}" } } } } }
now long locale set th
default date show current year plus 543:
i18n.locale = :th puts i18n.l(date.current) #=> "04.14.2558"
Comments
Post a Comment