Module: FFaker::Date

Extended by:
Date, ModuleUtils
Included in:
Date
Defined in:
lib/ffaker/date.rb

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, luhn_check, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#backward(days = 365) ⇒ Object

Generates a random date up to ‘days` days in the past



16
17
18
19
20
21
# File 'lib/ffaker/date.rb', line 16

def backward(days = 365)
  from = ::Date.today - days
  to   = ::Date.today - 1

  between(from, to)
end

#between(from, to) ⇒ Object

Generates a random date between 2 dates



11
12
13
# File 'lib/ffaker/date.rb', line 11

def between(from, to)
  FFaker::Time.between(from, to).to_date
end

#forward(days = 365) ⇒ Object

Generates a random date up to ‘days` days in the future



24
25
26
27
28
29
# File 'lib/ffaker/date.rb', line 24

def forward(days = 365)
  from = ::Date.today + 1
  to   = ::Date.today + days

  between(from, to)
end