''

def _update_epub_metadata(self, fpath, metadata):

    from calibre.utils.date import parse_date, now
    from calibre.ebooks.metadata.epub import set_metadata
    from lxml import etree
    from calibre.utils.zipfile import ZipFile
    if self.verbose:
        logger().info(('    %s._update_epub_metadata()' % self.__class__.__name__))
    metadata_x = self._xform_metadata_via_plugboard(metadata, 'epub')
    with lopen(fpath, 'r+b') as zfo:
        if False:
            try:
                zf_opf = ZipFile(fpath, 'r')
                fnames = zf_opf.namelist()
                opf = [x for x in fnames if ('.opf' in x)][0]
            except:
                raise UserFeedback(("'%s'    is    not    a    valid    EPUB" % metadata.title), None, level=UserFeedback.WARN)
            opf_tree = etree.fromstring(zf_opf.read(opf))
            md_els = opf_tree.xpath('.//*[local-name()="metadata"]')
            if md_els:
                ts = md_els[0].find('.//*[@name="calibre:timestamp"]')
                if (ts is not None):
                    timestamp = ts.get('content')
                    old_ts = parse_date(timestamp)
                    metadata.timestamp = datetime.datetime(old_ts.year, old_ts.month, old_ts.day, old_ts.hour, old_ts.minute, old_ts.second, (old_ts.microsecond + 1), old_ts.tzinfo)
                    if self.verbose:
                        logger().info(('            existing    timestamp:    %s' % metadata.timestamp))
                else:
                    metadata.timestamp = now()
                    if self.verbose:
                        logger().info(('            add    timestamp:    %s' % metadata.timestamp))
            else:
                metadata.timestamp = now()
                if self.verbose:
                    logger().warning('            missing    <metadata>    block    in    OPF    file')
                    logger().info(('            add    timestamp:    %s' % metadata.timestamp))
            zf_opf.close()
        if ((_('News') in metadata_x.tags) or (_('Catalog') in metadata_x.tags)):
            if (metadata_x.title.find('[') > 0):
                metadata_x.title = metadata_x.title[:(metadata_x.title.find('[') - 1)]
            date_as_author = ('%s,    %s    %s,    %s' % (strftime('%A'), strftime('%B'), strftime('%d').lstrip('0'), strftime('%Y')))
            metadata_x.author = metadata_x.authors = [date_as_author]
            sort_author = re.sub('^\\s*A\\s+|^\\s*The\\s+|^\\s*An\\s+', '', metadata_x.title).rstrip()
            metadata_x.author_sort = ('%s    %s' % (sort_author, strftime('%Y-%m-%d')))
        for tag in metadata_x.tags:
            if (not self._is_alpha(tag[0])):
                metadata_x.tags.remove(tag)
        if (iswindows and metadata_x.series):
            metadata_x.tags = None
        set_metadata(zfo, metadata_x, apply_null=True, update_timestamp=True)
