#!/usr/bin/env python3 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. """Prints number of days between today and another date Relies on datetime module to find the difference in dates Can handle any date, but dates in the past will be negative """ __all__ = ['main', 'input_opts'] __author__ = "Cody A. Taylor ( codemister99@yahoo.com )" __version__ = "1.1" import datetime, sys def main(): start_date = datetime.date(*input_opts()) today = datetime.date.today() days = (start_date - today).days weeks = days // 7 print("Today is: {}".format(today), "The starting date is: {}".format(start_date), "There are {} days left (about {} weeks)".format(days, weeks), sep="\n") def input_opts(): if len(sys.argv) == 2: date = sys.argv[1].split("-") elif len(sys.argv) >= 4: date = sys.argv[1:4] else: print("Usage: {} YEAR-MONTH-DAY".format(sys.argv[0]), "Usage: {} YEAR MONTH DAY".format(sys.argv[0]), " ", " Returns the days between the given date and today", sep="\n") sys.exit() return (int(x) for x in date) if __name__ == "__main__": main()