On 20Feb2015 21:14, Brad s <[email protected]> wrote:
Time adjustment error:# python3.4 timefix.py 2015022105 2015-02-21 05:00:00 Traceback (most recent call last): File "timefix.py", line 15, in <module> ndate = datetime.datetime.strptime(timeadd, '%Y%m%d%H') TypeError: must be str, not datetime.datetime # cat timefix.py #!/usr/bin/python3.4 import subprocess import sys from datetime import datetime import datetime from time import gmtime, strftime pretime = strftime("%Y%m%d%H", gmtime()) time = datetime.datetime.strptime(pretime,'%Y%m%d%H') print(pretime) print (time) plustime = datetime.timedelta(days=730) timeadd = (time + plustime) str(timeadd) ndate = datetime.datetime.strptime(timeadd, '%Y%m%d%H') #timeadd = timeadd.replace(tzinfo=UTC()) print (timeadd) print (ndate)
Well, timeadd is a date object, yes? strptime is for parsing a string for date information, but timeadd is already parsed, as it were. Why are you calling strptime at all?
Cheers, Cameron Simpson <[email protected]> stomping on roses and strangling kittens leaving no fingerprints cause we wear mittens inflatable prostitutes tied up with strings these are a few of my favorite things - gypsy <gypsy@popeet!c3.com> -- https://mail.python.org/mailman/listinfo/python-list
