'Update the Sony database from the book. This is done if the timestamp in
the db differs from the timestamp on the file.'

def update_text_record(self, record, book, path, bl_index, gtz_count, ltz_count, use_tz_var):

    try:
        timestamp = os.path.getmtime(path)
    except:
        debug_print('Failed    to    get    timestamp    for:', path)
        timestamp = time.time()
    rec_date = record.get('date', None)
    def clean(x):
        if isbytestring(x):
            x = x.decode(preferred_encoding, 'replace')
        x.replace(u'\x00', '')
        return x
    def record_set(k, v):
        try:
            record.set(k, clean(v))
        except:
            pass
    if (not getattr(book, '_new_book', False)):
        if (record.get('tz', None) is not None):
            use_tz_var = True
        if (strftime(timestamp, zone=time.gmtime) == rec_date):
            gtz_count += 1
        elif (strftime(timestamp, zone=time.localtime) == rec_date):
            ltz_count += 1
    else:
        if use_tz_var:
            tz = time.localtime
            record.set('tz', '0')
            debug_print("Use    localtime    TZ    and    tz='0'    for    new    book", book.lpath)
        elif (ltz_count >= gtz_count):
            tz = time.localtime
            debug_print('Use    localtime    TZ    for    new    book', book.lpath)
        else:
            tz = time.gmtime
            debug_print('Use    GMT    TZ    for    new    book', book.lpath)
        date = strftime(timestamp, zone=tz)
        record.set('date', clean(date))
    try:
        record.set('size', clean(str(os.stat(path).st_size)))
    except:
        record.set('size', '0')
    title = (book.title if book.title else _('Unknown'))
    record_set('title', title)
    ts = book.title_sort
    if (not ts):
        ts = title_sort(title)
    record_set('titleSorter', ts)
    if self.use_author_sort:
        if book.author_sort:
            aus = book.author_sort
        else:
            debug_print('Author_sort    is    None    for    book', book.lpath)
            aus = authors_to_sort_string(book.authors)
        record_set('author', aus)
    else:
        record_set('author', authors_to_string(book.authors))
    ext = os.path.splitext(path)[1]
    if ext:
        ext = ext[1:].lower()
        mime = MIME_MAP.get(ext, None)
        if (mime is None):
            mime = guess_type(('a.' + ext))[0]
        if (mime is not None):
            record.set('mime', clean(mime))
    if ('sourceid' not in record.attrib):
        record.set('sourceid', '1')
    if ('id' not in record.attrib):
        num = self.max_id(record.getroottree().getroot())
        record.set('id', str((num + 1)))
    return (gtz_count, ltz_count, use_tz_var)
