#!/usr/bin/env python
"""
@author Omar Bohsali
		omarish@virginia.edu
		
feed_parse.py -- Takes a twitter XML feed and parses the dates.

Makes the first time t=0, and all times after relative to that time in seconds.
"""


from xml.dom import minidom
import datetime


def make_timestamp(date):
	""" Takes a time string and converts it to a date object"""
	return  datetime.datetime.strptime(date, "%a %b %d %H:%M:%S +0000 %Y")

xmldoc = minidom.parse('friends_timeline_3k.xml')
body = xmldoc.childNodes[0]

first_date = body.getElementsByTagName('created_at')[0].firstChild.data
current = make_timestamp(first_date)

print "defining origin as %s ...\r" % first_date
dates = body.getElementsByTagName('created_at')
print "found %i records" % len(dates)


for node in dates:
	next = make_timestamp(node.firstChild.data)
	td = current - next
	current = next	
	print td.seconds
