Grape::Entity.format_with :utc do |date|
date.strftime('%Y年%m月%d日 %H:%M') if date
end
Grape::Entity.format_with :date do |date|
date.strftime('%Y年%m月%d日') if date
end
Grape::Entity.format_with :datetime do |date|
date.strftime('%Y年%m月%d日 %H:%M:%S') if date
end
Grape::Entity.format_with :rmb do |money, options|
ActiveSupport::NumberHelper.number_to_currency(money, unit: '元') if money
end
Grape::Entity.format_with :rmb_p0 do |money, options|
ActiveSupport::NumberHelper.number_to_currency(money, unit: '元', precision: 0) if money
end
Grape::Entity.format_with :round do |money|
ActiveSupport::NumberHelper.number_to_rounded(money, precision: 2).to_f if money
end