def from_isodatetime_2_timestamp(dtime, hours=0, minutes=0): """ Converts a ISO datetime to Unix Timestamp :param dtime: Datetime in YYYY-MM-DD HH:MM:SS format :param hours: Hours to adjust the timezone :param minutes: Minutes to adjust the timezone :return: Timestamp of the dtime """ p = _compile(r'(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})') m = p.search(dtime).groups() # year, month, day, hour, minute, second, microsecond t = _datetime(year=int(m[0]), month=int(m[1]), day=int(m[2]), hour=int(m[3]), minute=int(m[4]), second=int(m[5]), tzinfo=_timezone(_timedelta(hours=hours, minutes=minutes))) # UTC return int(t.timestamp())
def _get_local_tzinfo(): """ get local tzinfo @return: @rtype: """ dst = time.localtime().tm_isdst tz_offset = time.altzone if dst: tz_offset += 3600 td = _timedelta(seconds=-tz_offset) return _timezone(td)
def _get_local_tzinfo(): """ get local tzinfo @return: @rtype: """ dst = time.localtime().tm_isdst tz_offset = time.altzone if dst: tz_offset += 3600 td = _timedelta(seconds=-tz_offset) return _timezone(td) __tz_info = _timezone(_timedelta(0)) class DateStringError(BatchError, ValueError): pass class HandlerMismatch(DateStringError): pass # Begin list of handler functions for known formats. # We assume that the LabView software doesn't suck # at recording timestamps (though it kind of does, which # is why they don't all have the same format), and that # we don't need to check for errors, such as passing