# -*- coding: utf-8 -*- # Copyright (c) 2021, 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.builders import TupleBuilder from aniso8601.builders.python import PythonTimeBuilder from aniso8601.compat import is_string from aniso8601.date import parse_date from aniso8601.decimalfraction import normalize from aniso8601.exceptions import ISOFormatError from aniso8601.resolution import TimeResolution from aniso8601.timezone import parse_timezone TIMEZONE_DELIMITERS = ["Z", "+", "-"] def get_time_resolution(isotimestr): # Valid time formats are: # # hh:mm:ss # hhmmss # hh:mm # hhmm # hh # hh:mm:ssZ # hhmmssZ # hh:mmZ # hhmmZ # hhZ # hh:mm:ss±hh:mm # hhmmss±hh:mm # hh:mm±hh:mm # hhmm±hh:mm # hh±hh:mm # hh:mm:ss±hhmm # hhmmss±hhmm # hh:mm±hhmm # hhmm±hhmm # hh±hhmm # hh:mm:ss±hh # hhmmss±hh # hh:mm±hh # hhmm±hh # hh±hh isotimetuple = parse_time(isotimestr, builder=TupleBuilder) return _get_time_resolution(isotimetuple) def get_datetime_resolution(isodatetimestr, delimiter="T"): # T