I have a file of the following format
Summary:meeting Description:None DateStart:20100629T110000 DateEnd:20100629T120000 Time:20100805T084547Z
Summary:meeting Description:None DateStart:20100630T090000 DateEnd:20100630T100000 Time:20100805T084547Z
I need to create a function that would retrieve "Summary" at a given "date" and "time". For example the function would have two arguments, the date and time, which wont be in date time formats. It needs to check if the date and time specified in the function argument is between the date and times in the DateStart and DateEnd in the file.
I am not sure how to retrieve time and date from the format specified above [i.e., 20100629T110000]. I was trying to use the following
line_time = datetime.strptime(time, "%Y%D%MT%H%M%S")
, where time is "20100629T110000", but i am getting a lot of errors, like " datetime.datetime has not attribute strptime".
Whats the right way to do this function, thanks in advance.
....................EDIT................
Here is my error
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************
>>>
Traceback (most recent call last):
File "C:\Python24\returnCalendarstatus", line 24, in -toplevel-
status = calendarstatus()
File "C:\Python24\returnCalendarstatus", line 16, in calendarstatus
line_time = datetime.strptime(time, "%Y%m%dT%H%M%S")
AttributeError: type object 'datetime.datetime' has no attribute 'strptime'
>>>
And here is my code
import os
import datetime
import time
from datetime import datetime
def calendarstatus():
g = open('calendaroutput.txt','r')
lines = g.readlines()
for line in lines:
line=line.strip()
info=line.split(";")
summary=info[1]
description=info[2]
time=info[5];
line_time = datetime.strptime(time, "%Y%m%dT%H%M%S")
return line_time.year
status = calendarstatus()