Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#
#returns True
#
#durationstr = 'P1Y1M'
#components = ['P', 'Y', 'M', 'D']
#
#returns True
#
#durationstr = 'P1D1Y1M'
#components = ['P', 'Y', 'M', 'D']
#
#returns False
componentindex = 0
for characterindex in compat.range(len(durationstr)):
character = durationstr[characterindex]
if character in componentorder:
#This is a character we need to check the order of
if character in componentorder[componentindex:]:
componentindex = componentorder.index(character)
else:
#A character is out of order
return False
return True
# -*- coding: utf-8 -*-
# Copyright (c) 2016, Brandon Nielsen
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the BSD license. See the LICENSE file for details.
from aniso8601 import compat
class DateResolution(object):
Year, Month, Week, Weekday, Day, Ordinal = list(compat.range(6))
class TimeResolution(object):
Seconds, Minutes, Hours = list(compat.range(3))