myusuf3 / delorean

Delorean: Time Travel Made Easy
http://delorean.rtfd.org/
MIT License
1.84k stars 128 forks source link

Parsing string then converting to midnight and epoch. #82

Closed markorapaic closed 8 years ago

markorapaic commented 8 years ago

I'm trying to parse a string row[15] using the parse function, and then convert the result to midnight, and then convert that to epoch, however it keeps coming back with:

TypeError: 'datetime.datetime' object is not callable

What am I doing wrong, and is it possible to do the above? Ideally i'd like to be able to get it to show milliseconds too...

markorapaic commented 8 years ago

Also, when I try:

get_ref_date = parse(row[15]).midnight()
print(get_ref_date)

I get:

TypeError: 'datetime.datetime' object is not callable

markorapaic commented 8 years ago

I've since had another look at the documentation and have realised that midnight is not a function, but a property. I've changed this: get_ref_date = parse(row[15]).midnight However I still get the value error: ValueError: String does not contain a date.

myusuf3 commented 8 years ago

what is row[15]

markorapaic commented 8 years ago

I've ended up resolving this - the CSV I was looping through ended up having a field - row[15] - where I was expecting a date, but there actually was no date, hence it returned a value of None which is why the ValueError: String does not contain a date message was displayed (as it should!). User error, slightly embarrassed to be honest.

myusuf3 commented 8 years ago

@markorapaic This happens, shake it off. Been far more embarrassed in the past just be courteous when someone inevitably does it to you! :100: