How to deserialize with Python a JSON date exported with DataContractJsonSerializer?
Question: How to deserialize with Python a JSON date exported with
DataContractJsonSerializer?

The dates exported look like `/Date(1440051107000-0500)/` and I need to create
real DateTime objects in Python.

Is there an already existing code that does this, or I do have to code it
myself?


Answer: I think you'll find the answer in this thread: [Converting ASP.Net JSON Date
into Python datetime](http://stackoverflow.com/questions/18039625/converting-
asp-net-json-date-into-python-datetime)

Hope it helps.

EDIT: Following @SuperBiasedMan advice, here is the answer provided by the
link.

Apparently there is no code in python's standard library to cast this string
in a datetime object.

However, this code will do the trick:

    
    
    #!/usr/bin/env python
    
    import datetime
    
    EPOCH = datetime.datetime.utcfromtimestamp(0)
    
    def parse_date(datestring):
        timepart = datestring.split('(')[1].split(')')[0]
        milliseconds = int(timepart[:-5])
        hours = int(timepart[-5:]) / 100
        adjustedseconds = milliseconds / 1000 + hours * 3600
    
        return EPOCH + datetime.timedelta(seconds=adjustedseconds)
    
    ScheduleDate = "\/Date(1374811200000-0400)\/"
    StartTime = "\/Date(-2208931200000-0500)\/"
    
    print(parse_date(ScheduleDate))
    print(parse_date(StartTime))
    

