import re


def stripms(stamp):
    """
    Given ISO 8601 datestamp, strip out any milliseconds in representation
    using a regular expression safe for either stamps with or stamps
    without milliseconds included.
    """
    parts = stamp.split('.')
    if len(parts) == 1:
        return stamp  # no millisecond part; return original
    found = re.search('([0-9]*)([+-].*)', parts[1])
    if not found:
        return parts[0]  # no offset, so the first part is sufficent
    return '%s%s' % (parts[0], found.groups()[1])