Date and Time Generation¶
DateTimeGenerator supports fixed values, bounded random windows, weighted calendar/time selection, relative offsets, and epoch output. Its generated signature in the date/time generator reference is the version-specific parameter contract.
Fixed and bounded values¶
| fixed-and-bounded.xml | |
|---|---|
1 2 3 4 5 6 7 | |
Relative windows use the runtime clock anchor. A seeded execution uses the deterministic runtime clock; an unseeded execution intentionally reads the live clock.
Keep a datetime raw in a variable while later fields perform arithmetic, then format only the exported key. reference is deliberately a lookup contract, not arbitrary Python: it accepts a bare current-scope name, this.<field>, this.parent.<field>, or root.<field>. Calls, subscripts, and a bare parent.<field> are rejected.
Weighted selection¶
The generator can constrain months, weekdays, days of month, and time buckets. Weight lists select relative probability inside the corresponding domain; they do not change the requested record count.
Explicit month_weights, weekday_weights, dom_weights, hour_weights, minute_weights, or second_weights override sugar for the same dimension. Declarative string forms support literal lists, repetition such as '[1]*24', and concatenation such as '[0,0,1]+[0]*9'; list comprehensions and arbitrary expressions are not accepted.
| weighted-selection.xml | |
|---|---|
1 2 3 | |
Epoch output¶
Set as_epoch=True and select the implementation-supported epoch_unit when a numeric timestamp is required. Keep the consumer's unit explicit; seconds and milliseconds are not interchangeable.
For field conversion, inDateFormat="epoch" distinguishes seconds, milliseconds, microseconds, and nanoseconds by the supported digit lengths. outDateFormat accepts epoch, epoch_millis, epoch_micros, and epoch_nanos. Prefer this field-level form in XML; use generator as_epoch when the generated value itself must be numeric.
Invalid windows, weights, offsets, and formats use the central generator error catalog. Do not catch and reinterpret them in descriptor scripts.