'Format a datetime according to this calendar
@param dt: the datetime (datetime.datetime)
@return: the datetime as string'

def format_datetime(self, dt, dtfmt=None, local=False):

    if (dt is None):
        return current.messages['NONE']
    if (dtfmt is None):
        if local:
            dtfmt = current.deployment_settings.get_L10n_datetime_format()
        else:
            dtfmt = ISOFORMAT
    try:
        dtfmt = str(dtfmt)
    except (UnicodeDecodeError, UnicodeEncodeError):
        dtfmt = s3_unicode(dtfmt).encode('utf-8')
    if isinstance(dt, datetime.datetime):
        dt = dt.replace(microsecond=0)
    return self.calendar._format(dt, dtfmt)
