import re


def getTimeElementsFromString(dtStr):
    """Return tuple of (year,month,day,hour,minute,second) from date time string."""

    match = re.match(r'^(\d{4})[/-](\d{2})[/-](\d{2})[\s*T](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?Z?$',dtStr)
    if match: (year,month,day,hour,minute,second) = map(int,match.groups())
    else:
        match = re.match(r'^(\d{4})[/-](\d{2})[/-](\d{2})$',dtStr)
        if match:
            (year,month,day) = map(int,match.groups())
            (hour,minute,second) = (0,0,0)
        else: raise(RuntimeError("Failed to recognize date format: %s" % dtStr))
    return (year,month,day,hour,minute,second)