Last active
January 3, 2020 21:44
-
-
Save jinyangustc/43750da3cfbeee3fdd9aae522797b84a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
`datetime` is included in the standard library. | |
time format: | |
%d: Day of the month as a zero-padded decimal number. 01, 02, ..., 31 | |
%m: Month as a zero-padded decimal number. 01, 02, ..., 12 | |
%Y: Year with century as a decimal number. | |
%H: Hour (24-hour clock) as a zero-padded decimal number. 00, 01, ..., 23 | |
%M: Minute as a zero-padded decimal number. 00, 01, ..., 59 | |
""" | |
import datetime | |
# date + minute | |
start = "24-10-2019 00:00" | |
end = "11-11-2019 23:59" | |
european_format = "%d-%m-%Y %H:%M" | |
step_size = datetime.timedelta(minutes=1) | |
# date + hour | |
# start = "24-10-2019 00" | |
# end = "11-11-2019 23" | |
# european_format = "%d-%m-%Y %H" | |
# step_size = datetime.timedelta(hours=1) | |
t = datetime.datetime.strptime(start, european_format) | |
while t <= datetime.datetime.strptime(end, european_format): | |
print(t.strftime(european_format)) | |
t += step_size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run in command line:
python time_range.py > x_axis.txt