Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RandomDateTime

Random generator for Date time values.

Example

let value1 = RandomDateTime.nextDate(new Date(2010,0,1));    // Possible result: 2008-01-03
let value2 = RandomDateTime.nextDateTime(new Date(2017,0.1));// Possible result: 2007-03-11 11:20:32
let value3 = RandomDateTime.updateDateTime(new Date(2010,1,2));// Possible result: 2010-02-05 11:33:23

Hierarchy

  • RandomDateTime

Index

Methods

Static nextDate

  • nextDate(min: Date, max?: Date): Date
  • Generates a random Date in the range ['minYear', 'maxYear']. This method generate dates without time (or time set to 00:00:00)

    Parameters

    • min: Date

      (optional) minimum range value

    • Default value max: Date = null

      max range value

    Returns Date

    a random Date value.

Static nextDateTime

  • nextDateTime(min: Date, max?: Date): Date
  • 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: Date

      (optional) minimum range value

    • Default value max: Date = null

      max range value

    Returns Date

    a random Date and time value.

Static updateDateTime

  • updateDateTime(value: Date, range?: number): Date
  • Updates (drifts) a Date value within specified range defined

    Parameters

    • value: Date

      a Date value to drift.

    • Default value range: number = null

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

    Returns Date

Generated using TypeDoc