For persian_date
add jalalidate
to your gemfiles, then add this to ApplicationHelper
as helper (or any other place you want to use).
Default date format here is like (یکشنبه ۲۹ دی ۱۳۹۲ - ۰۳:۱۰
) for more format options see.
unpack
Snippet from a question in stackoverflow
module ApplicationHelper
def persian_numbers(str)
str ? str.unpack('U*').map{ |e| (0..9).to_a.include?(e-48) ? e + 1728 : e }.pack('U*') : ''
end
def persian_date(date)
date ? persian_numbers(JalaliDate.new(date).format("%A %d %b %Y - %H:%m")) : ''
end
end