How to use the aniso8601.parse_time function in aniso8601

To help you get started, we’ve selected a few aniso8601 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HearthSim / python-hslog / hslog / parser.py View on Github external
def parse_timestamp(self, ts, method):
		ret = parse_time(ts)

		if not self._synced_timestamp:
			# The first timestamp we parse requires syncing the time
			# (in case _current_date is greater than the start date)
			if self._current_date is not None:
				self._current_date = self._current_date.replace(
					hour=ret.hour,
					minute=ret.minute,
					second=ret.second,
					microsecond=ret.microsecond,
				)
			# Only do it once per parse tree
			self._synced_timestamp = True

		# Logs don't have dates :(
		if self._current_date is None:
github johnwheeler / flask-ask / flask_ask / convert.py View on Github external
def to_time(amazon_time):
    if amazon_time == "AM":
        return time(hour=0)
    if amazon_time == "PM":
        return time(hour=12)
    if amazon_time == "MO":
        return time(hour=5)
    if amazon_time == "AF":
        return time(hour=12)
    if amazon_time == "EV":
        return time(hour=17)
    if amazon_time == "NI":
        return time(hour=21)
    try:
        return aniso8601.parse_time(amazon_time)
    except ValueError as e:
        logger.warn("ValueError for amazon_time '{}'.".format(amazon_time))
        logger.warn("ValueError message: {}".format(e.message))
        return None
github graphql-python / graphene / graphene / types / datetime.py View on Github external
def parse_value(cls, value):
        try:
            if isinstance(value, datetime.time):
                return value
            elif isinstance(value, string_types):
                return parse_time(value)
        except ValueError:
            return None
github DBrianKimmel / PyHouse / Project / src / Modules / House / Schedule / schedule.py View on Github external
def _extract_time_part(self, p_timefield):
        """
        """
        try:
            l_time = aniso8601.parse_time(p_timefield)
        except Exception:
            l_time = datetime.time(0)
        return convert.datetime_to_seconds(l_time)
github HearthSim / python-hearthstone / hearthstone / hslog / parser.py View on Github external
def parse_timestamp(self, ts, method):
		ret = parse_time(ts)

		if not self._synced_timestamp:
			# The first timestamp we parse requires syncing the time
			# (in case _current_date is greater than the start date)
			if self._current_date is not None:
				self._current_date = self._current_date.replace(
					hour=ret.hour,
					minute=ret.minute,
					second=ret.second,
					microsecond=ret.microsecond,
				)
			# Only do it once per parse tree
			self._synced_timestamp = True

		# Logs don't have dates :(
		if self._current_date is None:
github DBrianKimmel / PyHouse / src / Modules / Housing / Scheduling / schedule.py View on Github external
def _get_schedule_timefield(p_schedule_obj):
    """
    """
    l_timefield = p_schedule_obj.Time.lower()
    try:
        # l_time = dparser.parse(l_timefield, fuzzy=True) # Worked ok in Python2
        l_time = aniso8601.parse_time(l_timefield)
    except ValueError:
        l_time = datetime.time(0)
    return l_time, l_timefield
github DBrianKimmel / PyHouse / src / Modules / Housing / Scheduling / schedule.py View on Github external
# print('==time== - {}'.format(l_timefield))

        l_subflag = False
        if '-' in l_timefield:
            # print(" found - ")
            l_subflag = True
            l_timefield = l_timefield[1:]
        elif '+' in l_timefield:
            # print(" found + ")
            l_subflag = False
            l_timefield = l_timefield[1:]
        l_timefield = l_timefield.strip()

        try:
            # l_time = dparser.parse(l_timefield, fuzzy=True)
            l_time = aniso8601.parse_time(l_timefield)
            # print('Parsable time field "{}" = "{}"'.format(l_timefield, l_time))
        except ValueError:
            # print('Unparsable time field "{}"'.format(l_timefield))
            l_time = datetime.time(0)

        l_offset = to_minutes(l_time)
        #
        #
        if l_subflag:
            l_minutes = l_base - l_offset
        else:
            l_minutes = l_base + l_offset
        #
        return l_minutes