This will return a datetime of utcnow - 6 hours for
        Central Standard Time
    :return: Datetime
184653
def cst_now():
    
    try:
        ret = datetime.utcnow() + timedelta(hours=DEFAULT_TIMEZONE)
        if DEFAULT_TIMEZONE_AWARE:
            ret = ret.replace(
                tzinfo=psycopg2.tz.FixedOffsetTimezone(
                    name=None, offset=DEFAULT_TIMEZONE * 60))
        return ret
    except Exception as ex:
        return datetime.utcnow() + timedelta(hours=DEFAULT_TIMEZONE)
282977
def now(cls, tzinfo=None):
    """"""
    obj = cls.utcnow()
    if tzinfo is None:
      tzinfo = localtz()
    return obj.astimezone(tzinfo)
801943
def get_now_utc_notz_datetime() -> datetime.datetime:
    
    now = datetime.datetime.utcnow()
    return now.replace(tzinfo=None)
522743
def to_time(dt, tzinfo=None, format=None):
    
    d = to_datetime(dt, tzinfo, format)
    if not d:
        return d
    return time_(d.hour, d.minute, d.second, d.microsecond, tzinfo=d.tzinfo)
435002
def datetime(self):
        
        if 'dt_scale' not in self._cache.keys():
            self._cache['dt_scale'] = self._datetime - timedelta(seconds=self._offset)
        return self._cache['dt_scale']
769796
def now(self, when=None):
        
        if when is None:
            when = _TaskManager().get_time()
        tup = time.localtime(when)

        self.value = (tup[0]-1900, tup[1], tup[2], tup[6] + 1)

        return self
31712
def today(self) -> datetime:
        
        self.value = datetime.combine(datetime.today().date(), time.min)
        return self.value
567605
def utctimetuple(self):
        ""
        offset = self.utcoffset()
        if offset:
            self -= offset
        y, m, d = self.year, self.month, self.day
        hh, mm, ss = self.hour, self.minute, self.second
        return _build_struct_time(y, m, d, hh, mm, ss, 0)
913749
def datetime(self):
        """"""
        return datetime.fromtimestamp(int(self.timestamp) / 1000, tz=pytz.utc)
992666
def getDayStart(self, dateTime):
        '''  '''
        return ensure_localtime(dateTime).replace(hour=0,minute=0,second=0,microsecond=0)
614203
def get_utc_date(entry):
    """"""
    if entry['numeric_date_stamp'] == '0':
        entry['numeric_date_stamp_utc'] = '0'
        return entry

    else:
        if '.' in entry['numeric_date_stamp']:
            t = datetime.strptime(entry['numeric_date_stamp'],
                    '%Y%m%d%H%M%S.%f')
        else:
            t = datetime.strptime(entry['numeric_date_stamp'],
                    '%Y%m%d%H%M%S')
        tdelta = timedelta(hours = int(entry['tzone'][1:3]),
                minutes = int(entry['tzone'][3:5]))

        if entry['tzone'][0] == '-':
            ut = t + tdelta
        else:
            ut = t - tdelta

        entry['numeric_date_stamp_utc'] = ut.strftime('%Y%m%d%H%M%S.%f')

        return entry
1088772
def _past_datetime_from(self):
        
        prevDt = self.__localBefore(timezone.localtime(), dt.time.max,
                                    excludeCancellations=True,
                                    excludeExtraInfo=True)
        return prevDt
350493
def utc_dt(dt):
    
    if not dt.tzinfo:
        return pytz.utc.localize(dt)
    return dt.astimezone(pytz.utc)
147973
def getUTC(self, utcoffset):
        
        newTime = (self.value - utcoffset.value) % 24
        return Time(newTime)
612386
def dst(self, dt):
        
        if not self._is_dst(dt):
            return datetime.timedelta(0)

        offset = time.timezone - time.altzone
        return datetime.timedelta(seconds=-offset)
902065
def to_utc_datetime(self, value):
        
        value = self.to_naive_datetime(value)

        if timezone.is_naive(value):
            value = timezone.make_aware(value, timezone.utc)
        else:
            value = timezone.localtime(value, timezone.utc)
        return value
408303
def get_last_an_time(self, utc_time):
        

        # Propagate backwards to ascending node
        dt = np.timedelta64(10, 'm')
        t_old = utc_time
        t_new = t_old - dt
        pos0, vel0 = self.get_position(t_old, normalize=False)
        pos1, vel1 = self.get_position(t_new, normalize=False)
        while not (pos0[2] > 0 and pos1[2] < 0):
            pos0 = pos1
            t_old = t_new
            t_new = t_old - dt
            pos1, vel1 = self.get_position(t_new, normalize=False)

        # Return if z within 1 km of an
        if np.abs(pos0[2]) < 1:
            return t_old
        elif np.abs(pos1[2]) < 1:
            return t_new

        # Bisect to z within 1 km
        while np.abs(pos1[2]) > 1:
            # pos0, vel0 = pos1, vel1
            dt = (t_old - t_new) / 2
            t_mid = t_old - dt
            pos1, vel1 = self.get_position(t_mid, normalize=False)
            if pos1[2] > 0:
                t_old = t_mid
            else:
                t_new = t_mid

        return t_mid