Sha256: aea7f9172881880089d215cd999270b6ee6cd04d4650be976252127e8be68535
Contents?: true
Size: 910 Bytes
Versions: 1
Compression:
Stored size: 910 Bytes
Contents
# frozen_string_literal: true require 'date' module FFaker module Date extend FFaker::ModuleUtils extend self # Generates a random date between 2 dates def between(from, to) FFaker::Time.between(from, to).to_date end # Generates a random date up to `days` days in the past def backward(days = 365) from = ::Date.today - days to = ::Date.today - 1 between(from, to) end # Generates a random date up to `days` days in the future def forward(days = 365) from = ::Date.today + 1 to = ::Date.today + days between(from, to) end # Random birthday date (maximum age between 18 and 65) # Keyword arguments: min_age, max_age def birthday(min_age: 18, max_age: 65) from = ::Date.today.prev_year(max_age + 1).next_day to = ::Date.today.prev_year(min_age) between(from, to) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ffaker-2.23.0 | lib/ffaker/date.rb |