On Thu, Oct 18, 2012 at 11:55 PM, Steven D'Aprano <st...@pearwood.info> wrote: > > Have you tried running `date` at the Windows command.com (or cmd.exe, > or something, I never remember which)? What does it print? > > My guess is that it probably prints something like: > > "Command not found" > > which clearly cannot be parsed as a date.
Windows has separate date and time commands ('date /t' and 'time /t'), but it's simpler to use 'echo %time% %date%' in the shell. Also, the demo script isn't for Python 3.x. It uses "print" as a statement and the "commands" module, which is deprecated in 2.x and removed from 3.x. Try this instead: import sys import os import subprocess from dateutil.relativedelta import * from dateutil.easter import * from dateutil.rrule import * from dateutil.parser import * from datetime import * if sys.platform == 'win32': cmd = 'echo %time% %date%' shell = True else: cmd = 'date' shell = False datestr = subprocess.check_output(cmd, shell=shell).decode() now = parse(datestr) today = now.date() year = rrule(YEARLY,bymonth=8,bymonthday=13,byweekday=FR)[0].year rdelta = relativedelta(easter(year), today) print("Today is:", today) print("Year with next Aug 13th on a Friday is:", year) print("How far is the Easter of that year:", rdelta) print("And the Easter of that year is:", today+rdelta) _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor