Sha256: 7ffe32ac80092e53af3b2acfdafe3ed5de98e96df7d4e9119f81ec5f9f950b40

Contents?: true

Size: 944 Bytes

Versions: 88

Compression:

Stored size: 944 Bytes

Contents

# encoding: utf-8
class Date

  def self.year(year=Date.today.year)
    Date.new(year)
  end

  def january(day=nil)
    day.nil?? self.change(month: 1) : self.change(month: 1, day: day)
  end

  def october(day=nil)
    day.nil?? self.change(month: 10) : self.change(month: 10, day: day)
  end

  def december(day=nil)
    day.nil?? self.change(month: 12) : self.change(month: 12, day: day)
  end

  def monday
    self - (self.wday - 1) % 7
  end

  def weekend?
    self.wday == 0 || self.wday == 6
  end

  def display
    "#{Configuration::DAYS[self.wday]} #{self.day} de #{Configuration::MONTHS[self.month-1]} #{self.year == Date.today.year ? '' : self.year}"
  end

  def short_display
    self.strftime('%d/%m/%Y')
  end

  def next_working_date
    add_working_days(1)
  end

  def prev_working_date
    add_working_days(-1)
  end

  def first_monday_before
    return self if self.monday?
    (self - 1).first_monday_before
  end

end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
sinatra-hexacta-1.6.3 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.6.2 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.6.1 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.6.0 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.5.3 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.5.2 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.5.1 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.5.0 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.4.4 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.4.3 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.4.2 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.4.1 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.4.0 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.3.0 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.2.10 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.2.9 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.2.8 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.2.7 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.2.6 lib/sinatra/extensions/date.rb
sinatra-hexacta-1.2.5 lib/sinatra/extensions/date.rb