Skip to content

DateTimeGenerator generator

Generate fixed, ranged, weighted, offset, or reference-relative date-time values.

Why: Use DateTimeGenerator to model bounded, deterministic date-time requirements such as ranges, business-hour weighting, offsets, and dependencies on another field.

Category: core.

Output: datetime | int.

1
<key name="value" generator="DateTimeGenerator(min='2026-01-01', max='2026-12-31', random=True, input_format='%Y-%m-%d')"/>

Parameters

  • min: str | null; Default None β€” Inclusive lower date-time bound parsed with input_format when supplied.
  • max: str | null; Default None β€” Inclusive upper date-time bound parsed with input_format when supplied.
  • value: str | null; Default None β€” Fixed date-time value; incompatible with random or offset modes.
  • random: bool | null; Default False β€” Whether to draw a value from the configured bounded window.
  • random_mode: bool | null; Default None β€” Explicit alias for selecting random-window generation.
  • input_format: str | null; Default None β€” Python datetime format used to parse min, max, and value strings.
  • hour_weights: list[float] | null; Default None β€” Twenty-four relative weights controlling hour-of-day selection.
  • minute_weights: list[float] | null; Default None β€” Sixty relative weights controlling minute selection.
  • second_weights: list[float] | null; Default None β€” Sixty relative weights controlling second selection.
  • month_weights: list[float] | null; Default None β€” Twelve relative weights controlling month selection.
  • weekday_weights: list[float] | null; Default None β€” Seven relative weights controlling Monday-through-Sunday selection.
  • dom_weights: list[float] | null; Default None β€” Relative weights controlling valid days of a month.
  • months: str | list[int] | null; Default None β€” Allowed month numbers, ranges, or names used to constrain the window.
  • months_exclude: str | list[int] | null; Default None β€” Month numbers, ranges, or names removed from the allowed window.
  • weekdays: str | list[int | str] | null; Default None β€” Allowed weekday numbers or names.
  • dom: str | list[int | str] | null; Default None β€” Allowed day-of-month values; supports implementation-defined last-day notation.
  • hours_preset: str | null; Default None β€” Named hour window such as business hours.
  • minute_granularity: int | null; Default None β€” Positive minute step to which generated values are aligned.
  • second_granularity: int | null; Default None β€” Positive second step to which generated values are aligned.
  • offset: str | null; Default None β€” ISO 8601 duration or arithmetic offset applied to the base value.
  • max_offset: str | null; Default None β€” Maximum offset used when a bounded random offset is required.
  • reference: str | null; Default None β€” Field reference whose resolved date-time becomes the offset base.
  • as_epoch: bool; Default False β€” Whether to return an integer epoch instead of a datetime value.
  • epoch_unit: str; Default seconds β€” Epoch precision: seconds or milliseconds.