Bỏ qua

Date and time generators

Warning

The current page still doesn't have a translation for this language.

But you can help translating it: Contributing.

Date and time use cases

BirthdateGenerator

Generate a date of birth within configurable minimum and maximum ages.

Why: Use BirthdateGenerator when a person's date of birth must satisfy an inclusive age range at the run's reference date; use DateTimeGenerator for dates that are not age-derived.

Category: person.

Output: datetime.

1
<key name="value" generator="BirthdateGenerator(min_age=18, max_age=67)"/>

Parameters

  • min_age: int; Default 1 — Inclusive minimum age represented by the generated birthdate.
  • max_age: int; Default 100 — Inclusive maximum age represented by the generated birthdate.

DateTimeGenerator

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.