python/dna/time_utils.py
def normalize_date_format(date):
    '''
    Dates can be defined in many ways, but zipline use
    aware datetime objects only. Plus, the software work
    with utc timezone so we convert it.
    '''
    if isinstance(date, int):
        # This is probably epoch time
        date = time.strftime('%Y-%m-%d %H:%M:%S',
                             time.localtime(date))

    # assert isinstance(date, str) or isinstance(date, unicode)
    if isinstance(date, str) or isinstance(date, unicode):
        date = dateutil.parser.parse(date)
    if not date.tzinfo:
        local_tz = pytz.timezone(_detect_timezone())
        local_dt = local_tz.localize(date, is_dst=None)
        # TODO I'm not sure why and when I need to add a date to make it right
        date = local_dt.astimezone(pytz.utc) + pd.datetools.day

    return date
def normalize_date_format(date):
    '''
    Dates can be defined in many ways, but zipline use
    aware datetime objects only. Plus, the software work
    with utc timezone so we convert it.
    '''
    if isinstance(date, int):
        # This is probably epoch time
        date = time.strftime('%Y-%m-%d %H:%M:%S',
                             time.localtime(date))

    # assert isinstance(date, str) or isinstance(date, unicode)
    if isinstance(date, str) or isinstance(date, unicode):
        date = dateutil.parser.parse(date)
    if not date.tzinfo:
        local_tz = pytz.timezone(_detect_timezone())
        local_dt = local_tz.localize(date, is_dst=None)
        # TODO I'm not sure why and when I need to add a date to make it right
        date = local_dt.astimezone(pytz.utc) + pd.datetools.day

    return date
def normalize_date_format ( date ) : if isinstance ( date , int ) : # This is probably epoch time date = time . strftime ( '%Y-%m-%d %H:%M:%S' , time . localtime ( date ) ) # assert isinstance(date, str) or isinstance(date, unicode) if isinstance ( date , str ) or isinstance ( date , unicode ) : date = dateutil . parser . parse ( date ) if not date . tzinfo : local_tz = pytz . timezone ( _detect_timezone ( ) ) local_dt = local_tz . localize ( date , is_dst = None ) # TODO I'm not sure why and when I need to add a date to make it right date = local_dt . astimezone ( pytz . utc ) + pd . datetools . day return date
Dates can be defined in many ways, but zipline use
    aware datetime objects only. Plus, the software work
    with utc timezone so we convert it.
Dates can be defined in many ways but zipline use aware datetime objects only . Plus the software work with utc timezone so we convert it .