How to use the aniso8601.parse_repeating_interval 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 sqlxpert / aws-tag-sched-ops / age_backups.py View on Github external
interval = (
      f"{repeat_part}/{date_context_part}/{duration_part}"
      if context_forward else
      f"{repeat_part}/{duration_part}/{date_context_part}"
    )
    print(LOG_LINE_FMT.format(
      code=9,
      region="",
      parent_rsrc_id="",
      rsrc_id="",
      op="",
      note=f"Interval {interval_in} translation: {interval}"
    ))
    try:
      dates = aniso8601.parse_repeating_interval(interval, relative=True)
    except aniso8601.exceptions.ISOFormatError as exc:
      err_str = str(exc)
    # TODO: Remove next clause when aniso8601 bug is fixed:
    # https://bitbucket.org/nielsenb/aniso8601/issues/18/parsing-time-throw-a-valueerror-instead-of#comment-45727132
    except ValueError as exc:
      err_str = str(exc)
  else:
    err_str = (
      "Must be a valid ISO 8601 interval, repeating or non-, with a duration,"
      " no decimal, hour 0-4, 6 or 12, minute 0, 10, 20 or 30, and second 0."
    )

  if err_str:
    print(LOG_LINE_FMT.format(
      code=9,
      region="",
github CounterpartyXCP / counterblock / counterblock / lib / util.py View on Github external
def parse_iso8601_interval(value):
    try:
        return aniso8601.parse_interval(value)
    except Exception:
        try:
            return aniso8601.parse_repeating_interval(value)
        except Exception:
            raise FormatError('{} is not an iso8601 interval'.format(value))