date Mode
In date mode, date values are generated. The format of the command is as follows:
randog date [MINIMUM MAXIMUM] [--iso | --fmt FORMAT] [common-options]
Arguments and Options
MINIMUM
(optional):MAXIMUM
(optional):--iso
(optional):if specified, it outputs generated object with ISO-8601 format.
--fmt FORMAT
(optional):if specified, it outputs generated object with the specified format; The format is specified in the form of strftime or strptime.
common-options
Expression of MINIMUM and MAXIMUM
You can specify the arguments MINIMUM
and MAXIMUM
with following expressions:
today
: it means current dateISO-8601 format, such as
2022-01-01
.date combined with simple format of timedelta, such as
today+2d
, or,2022-01-01-1d
.simple format of timedelta (date term is omitted), such as
+2d
:, or,-7d
If the other (MAXIMUM or MINIMUM) is specified with date term, it means the other plus the timedelta.
If the other (MAXIMUM or MINIMUM) is fully omitted or date term of the other is omitted, it means
today
plus the timedelta.
Note
A simple expression such as -7d
can be used, but since it begins with -
, it is interpreted as an optional argument and will cause an error. To avoid this, it must be specified after --
, as in the following example.
# valid (example for usage with --repeat)
randog date --repeat 10 -- -7d +7d
# invalid (unknown option -30m)
randog date --repeat 10 -7d +7d
Examples
The simplest example is the following, which outputs a date value.
randog date
You can specify a range of values to be generated, as in the following example:
# generates a value between 2021-01-01 and 2021-01-31
randog date 2021-01-01 2021-01-31
# generates a value between yesterday and tomorrow
randog date -- -1d +1d
# generates a value between 7 days ago and today
randog date -- -7d
# generates a value between today and 1 day later
randog date +1d
Note
See Expression of MINIMUM and MAXIMUM for expressions such as +1d
.
Format: ISO-8601, etc.
By default, the output is in the standard python format, but you can change the output format to the format specified in the form of strftime or strptime or ISO-8601 format by specifying options as follows:
# generates a value with ISO-8601 format
randog date --iso
# generates a value with the specified format
randog date --fmt '%Y/%m/%d'
Repeatedly Generate
Most likely, you will not be satisfied with just one generated, so you will probably want to output multiple times as follows:
# Repeat 10 times
randog date -r 10
# Generate list which contains 10 values
randog date -L 10 --json --iso
Note
In date mode, time in a date is not generated simultaneously. If both is wanted, use datetime mode.