Sha256: d01b3d7e7f017f59b8fdafeff1ad74bc51e5af33ef9924e39a32f2a2dac4413e

Contents?: true

Size: 346 Bytes

Versions: 4

Compression:

Stored size: 346 Bytes

Contents

class Date
  def self.parse_or_return(unparsed_date)
    return unparsed_date unless unparsed_date.is_a?(String)

    Date.parse(unparsed_date)
  end

  def humanize
    case self
    when Date.today.prev_day
      'yesterday'
    when Date.today
      'today'
    when Date.today.succ
      'tomorrow'
    else
      self.to_s
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nin-1.3.0 lib/nin/extensions/date_extensions.rb
nin-1.2.0 lib/nin/extensions/date_extensions.rb
nin-1.0.1 lib/nin/extensions/date_extensions.rb
nin-1.0.0 lib/nin/extensions/date_extensions.rb