pip_services3_commons.random.RandomDateTime module

pip_services3_commons.random.RandomDateTime

RandomDateTime implementation

copyright

Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.

license

MIT, see LICENSE for more details.

class pip_services3_commons.random.RandomDateTime.RandomDateTime

Bases: object

Random generator for Date time values.

Example:

(month must be in 1..12)
value1 = RandomDateTime.next_date(datetime.datetime(2010,1,1))       # Possible result: 2008-01-03
value2 = RandomDateTime.next_datetime(datetime.datetime(2017,1,1))   # Possible result: 2007-03-11 11:20:32
value3 = RandomDateTime.update_datetime(datetime.datetime(2010,1,2)) # Possible result: 2010-02-05 11:33:23
static next_date(min_year: <module 'datetime' from '/usr/local/lib/python3.10/datetime.py'>, max_year: <module 'datetime' from '/usr/local/lib/python3.10/datetime.py'> = None) → <module ‘datetime’ from ‘/usr/local/lib/python3.10/datetime.py’>

Generates a random Date in the range [‘min_year’, ‘max_year’]. This method generate dates without time (or time set to 00:00:00

Parameters
  • min_year – min range args

  • max_year – (optional) maximum range args

Returns

a random Date and time args.

static next_datetime(min_year: <module 'datetime' from '/usr/local/lib/python3.10/datetime.py'>, max_year: <module 'datetime' from '/usr/local/lib/python3.10/datetime.py'> = None) → <module ‘datetime’ from ‘/usr/local/lib/python3.10/datetime.py’>

Generates a random Date and time in the range [‘minYear’, ‘maxYear’]. This method generate dates without time (or time set to 00:00:00)

Parameters
  • min_year – min range args

  • max_year – (optional) maximum range args

Returns

a random Date and time args.

static update_datetime(value: <module 'datetime' from '/usr/local/lib/python3.10/datetime.py'>, range: Union[int, float] = None) → <module ‘datetime’ from ‘/usr/local/lib/python3.10/datetime.py’>

Updates (drifts) a Date args within specified range defined

Parameters
  • value – a Date args to drift.

  • range – (optional) a range in milliseconds. Default: 10 days

Returns

an updated DateTime args.