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 date as “YYYY-MM-DD” (e.g. “1999-12-31”). Shortcut for strftime(“%Y-%m-%d”).

Returns:

  • (String)

    the date formatted as “YYYY-MM-DD”



9
10
11
12
13
14
# File 'lib/casual_support/date/to_ymd.rb', line 9

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