Skip to content

Instantly share code, notes, and snippets.

@jinyangustc
Last active January 3, 2020 21:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jinyangustc/43750da3cfbeee3fdd9aae522797b84a to your computer and use it in GitHub Desktop.
Save jinyangustc/43750da3cfbeee3fdd9aae522797b84a to your computer and use it in GitHub Desktop.
"""
`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
@jinyangustc
Copy link
Author

jinyangustc commented Nov 13, 2019

Run in command line:

python time_range.py > x_axis.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment