module TimeInstance
时间类型相关类通用实例方法定义模块。
@author shiner527 <shiner527@hotmail.com>
Public Instance Methods
format_date(type = :date)
click to toggle source
时间格式化为指定的字符串。
@param [Symbol] type 指定需要转换的具体格式。默认为 :date
类型的格式。
@return [String] 返回转换后的字符串。
# File lib/activemodel_object_info/extends/ruby_generals.rb, line 16 def format_date(type = :date) case type when :full strftime('%Y-%m-%d %H:%M:%S') when :min strftime('%Y-%m-%d %H:%M') when :date strftime('%Y-%m-%d') when :year strftime('%Y') end end