Class: Date

Inherits:
Object
  • Object
show all
Defined in:
lib/casual_support/date/to_ymd.rb

Instance Method Summary collapse

Instance Method Details

#to_ymdString

Formats the Date as “YYYY-MM-DD”. Equivalent to strftime(“%Y-%m-%d”).

Examples:

Date.new(1999, 12, 31).to_ymd  # == "1999-12-31"

Returns:



12
13
14
15
16
17
# File 'lib/casual_support/date/to_ymd.rb', line 12

def to_ymd
  # Date#strftime appears to be **much** faster than Time#strftime
  # (nearly 3x faster!).  Thus it is used here, unlike Time#to_ymd
  # which uses sprintf.
  self.strftime('%Y-%m-%d'.freeze)
end