'Get a string representation for a datetime.datetime according
to this calendar and dtfmt, to be implemented by subclass
@param dt: the datetime.datetime
@param dtfmt: the datetime format (strftime)
@return: the string representation (str)
@raises TypeError: for invalid argument types'

def _format(self, dt, dtfmt):

    if (self.name == 'Gregorian'):
        fmt = str(dtfmt)
        try:
            dtstr = dt.strftime(fmt)
        except ValueError:
            year = ('%04i' % dt.year)
            fmt = fmt.replace('%Y', year).replace('%y', year[(-2):])
            dtstr = dt.replace(year=1900).strftime(fmt)
        except AttributeError:
            raise TypeError(('Invalid    argument    type:    %s' % type(dt)))
    else:
        if (not isinstance(dt, datetime.datetime)):
            try:
                timetuple = (dt.year, dt.month, dt.day, 0, 0, 0)
            except AttributeError:
                raise TypeError(('Invalid    argument    type:    %s' % type(dt)))
        else:
            timetuple = (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
        formatter = S3DateTimeFormatter(self)
        dtstr = formatter.render(self._cdate(timetuple), dtfmt)
    return dtstr
