time Mode

In time mode, time values are generated. The format of the command is as follows:

randog time [MINIMUM MAXIMUM] [--iso | --fmt FORMAT] [common-options]

Arguments and Options

  • MINIMUM (optional):

    • the minimum value; see also here. If not specified, the behavior is left to the specification of randtime.

  • MAXIMUM (optional):

    • the maximum value; see also here. If not specified, the behavior is left to the specification of randtime.

  • --iso (optional):

  • --fmt FORMAT (optional):

  • common-options

Expression of MINIMUM and MAXIMUM

You can specify the arguments MINIMUM and MAXIMUM with following expressions:

  • now: it means current time

  • ISO-8601 format, such as 11:22:33.000000, or, 11:22:33.

  • time combined with simple format of timedelta, such as now+2h, or, 01:00:00-1h30m.

  • simple format of timedelta (time term is omitted), such as +2h:, or, -30m

    • If the other (MAXIMUM or MINIMUM) is specified with time term, it means the other plus the timedelta.

    • If the other (MAXIMUM or MINIMUM) is fully omitted or time term of the other is omitted, it means now plus the timedelta.

Note

A simple expression such as -30m 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 time --repeat 10 -- -30m +30m

# invalid (unknown option -30m)
randog time --repeat 10 -30m +30m

Examples

The simplest example is the following, which outputs a time value.

randog time

You can specify a range of values to be generated, as in the following example:

# generates a value between 00:00:00 and 12:00:00
randog time 00:00:00 12:00:00

# generates a value between 1 hour ago and 1 hour later
randog time -- -1h +1h

# generates a value between 12 hours ago and now
randog time -- -12h

# generates a value between now and 30 minutes later
randog time +30m

Note

See Expression of MINIMUM and MAXIMUM for expressions such as +1h.

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 time --iso

# generates a value with the specified format
randog time --fmt '%H:%M'

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 time -r 10

# Generate list which contains 10 values
randog time -L 10 --json --iso

Note

In time mode, date is not generated simultaneously. If both is wanted, use datetime mode.

Also, if you want to generate an elapsed time rather than a time that points to a certain point in time, use timedelta mode.