Buddhist Era in Ruby on Rails by divineforest
In Thailand and some other countries it's already 2555 year since they use Buddhist Calendar and there is offset of 543 to gregorian one. Not a problem in #ruby and #i18n As i18n support not only YAML files but ruby hashes also it can be easily localized.
cat config/locales/th.rb
{
th: {
date: {
formats: {
default: lambda { |date, _| "%d.%m.#{date.year + 543}" }
}
}
}
}
and then just use I18n.l method:
ruby-1.9.3-p194 :032 > I18n.l(Date.current)
=> "30.10.2555"
Comments
kirs commented 7 months ago
Tricky :)
makaroni4 commented 7 months ago