Reputation: 79
I have a script which perform several things when executed, it accepts --start_date=SOMEDATE
, --end_date=SOMEDATE
, and --actions=200
.
For example:
python3 myscript --start_date=2019-02-12 --end_date=2020-02-01 --actions=100
Which means it has to make 100 actions
between the start_date
and end_date
. Is there a way to calculate the times?
Here is the logic I'm considering:
There are 31 days between the start and end dates, so maybe actions // (end_date - start_date)
gives me the number of actions per day, but how can I make those actions per day completely random within the day?
Upvotes: 0
Views: 80
Reputation: 176
What I would do is get the unix timestamps. Do
upper_bound = timestamp_end - timestamp_start
Where the timestamp_start
and timestamp_end
are the start and end dates.
Then generate N
random numbers between 0
and upperbound
.
Afterwards just execute the script at timestamp_start + random_number
Upvotes: 2