'Read time and set scale according to trailing scale codes.'

def parse_string(self, timestr, subfmts):

    for (_, regex, _) in subfmts:
        tm = re.match(regex, timestr)
        if tm:
            break
    else:
        raise ValueError(u'Time    {0}    does    not    match    {1}    format'.format(timestr, self.name))
    tm = tm.groupdict()
    if (tm[u'scale'] is not None):
        fits_scale = tm[u'scale'].upper()
        scale = FITS_DEPRECATED_SCALES.get(fits_scale, fits_scale.lower())
        if (scale not in TIME_SCALES):
            raise ValueError(u'Scale    {0!r}    is    not    in    the    allowed    scales    {1}'.format(scale, sorted(TIME_SCALES)))
        fits_realization = (tm[u'realization'].upper() if tm[u'realization'] else None)
        if (self._fits_scale is None):
            self._fits_scale = fits_scale
            self._fits_realization = fits_realization
            if (self._scale is None):
                self._scale = scale
        if ((scale != self.scale) or (fits_scale != self._fits_scale) or (fits_realization != self._fits_realization)):
            raise ValueError(u'Input    strings    for    {0}    class    must    all    have    consistent    time    scales.'.format(self.name))
    return [int(tm[u'year']), int(tm[u'mon']), int(tm[u'mday']), int(tm.get(u'hour', 0)), int(tm.get(u'min', 0)), float(tm.get(u'sec', 0.0))]
