Title: Signature.html
Here's as far as I can go with this. The last line of output asks the
question I need an answer for.
(Once again my direct post to tutor@python.org has failed to appear
here (sent 5:42 PDT), as before.)
# Using datetime to do date-time math on a file date-time
stamp and
# the creating the new stamp
import datetime
def adjust_ftime(atime, sec):
# yyyymmdd_hhmmss, seconds in, new yyyymmdd_hhmmss out
ts = atime[1:-7] # use time stamp portion
ayear = int(ts[0:4])
amonth = int(ts[4:6])
aday = int(ts[6:8])
ahour = int(ts[9:11])
aminute = int(ts[11:13])
asecond = int(ts[13:15])
print ayear, amonth, aday, asecond
dt1 = datetime.datetime(ayear, amonth, aday, ahour, aminute,
asecond)
print dt1, type(dt1)
delta = datetime.timedelta(seconds = 200)
dt2 = dt1 + delta
print dt2, type(dt2)
print "what next? I need the result 20080321_113405"
new_fstamp = "zippo"
return (new_fstamp)
filename = 'v20080321_113045.27.txt'
print adjust_ftime(filename, 2.3)
Results:
2008 3 21 45
2008-03-21 11:30:45 <type 'datetime.datetime'>
2008-03-21 11:34:05 <type 'datetime.datetime'>
what next? I need the result 20080321_113405
--
Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
"If voting made any difference they wouldn't let us do it."
-- Mark Twain
Web Page: <www.speckledwithstars.net/>
|
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor