iterate over specified date range
This commit is contained in:
parent
b730441f65
commit
4498feb07d
|
@ -13,6 +13,10 @@ to_date = datetime.date.today()
|
|||
|
||||
def main():
|
||||
parse_config()
|
||||
for single_date in daterange(from_date, to_date):
|
||||
if verbose:
|
||||
print("Processing date", single_date)
|
||||
build_day(single_date)
|
||||
|
||||
def parse_config():
|
||||
global mediadir, playlistdir, channel, verbose, from_date, to_date
|
||||
|
@ -39,9 +43,9 @@ def parse_config():
|
|||
if args.channel:
|
||||
channel = args.channel
|
||||
if args.from_date:
|
||||
from_date = datetime.strptime(args.from_date, "%Y-%m-%d")
|
||||
from_date = datetime.datetime.strptime(args.from_date, "%Y-%m-%d").date()
|
||||
if args.to_date:
|
||||
to_date = datetime.strptime(args.to_date, "%Y-%m-%d")
|
||||
to_date = datetime.datetime.strptime(args.to_date, "%Y-%m-%d").date()
|
||||
|
||||
if verbose:
|
||||
print("Arguments parsed, config:")
|
||||
|
@ -51,6 +55,14 @@ def parse_config():
|
|||
print("from_date:", from_date)
|
||||
print("to_date:", to_date)
|
||||
|
||||
def build_day(this_date):
|
||||
# todo
|
||||
pass
|
||||
|
||||
# generator function to yield single dates from a date range
|
||||
def daterange(start_date, end_date):
|
||||
for n in range(int((end_date - start_date).days) + 1): # adding 1 to make the range inclusive
|
||||
yield start_date + datetime.timedelta(n)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue