I am getting a random datetime between two datetimes with following code
start_date = datetime.datetime(2013, 1, 1, tzinfo=pytz.UTC).toordinal()
end_date = datetime.datetime.now(tz=pytz.utc).toordinal()
return datetime.date.fromordinal(random.randint(start_date, end_date))
The problem is that it is not timezone aware.
I have already tried making it timezone aware by using tzinfo=pytz.UTC
as seen in the code above but it doesn't work. I guess datetime.date.fromordinal()
makes it a naive datetime format.