<commit_before>from docutils.core import publish_parts
from flask import current_app
import pytz, datetime, urllib


def _local_tz(dt):
    return dt.astimezone(current_app.config['local_timezone'])

def timefilter(dt):
    return _local_tz(mkdate(dt)).time()

def datefilter(dt):
    return _local_tz(mkdate(dt)).strftime('%d. %b %Y')

def datetimefilter(dt):
    return _local_tz(mkdate(dt))

def datecode(dt):
    return dt.strftime('%Y-%m-%d')

def datetimecode(dt):
    return dt.strftime('%Y-%m-%dT%H:%M:%SZ')

def rst(value):
    return publish_parts(value, writer_name='html',
            settings_overrides={'initial_header_level':2})['body']

def mkdate(v):
    if isinstance(v, datetime.datetime):
        return v
    return datetime.datetime.utcfromtimestamp(float(v)).replace(tzinfo=pytz.utc)

def urlencode(v):<commit_msg>Fixed a unicode related issue with the datetime filters<commit_after>from docutils.core import publish_parts
from flask import current_app
import pytz, datetime, urllib


def _local_tz(dt):
    return dt.astimezone(current_app.config['local_timezone'])

def timefilter(dt):
    return _local_tz(mkdate(dt)).time()

def datefilter(dt):
    return _local_tz(mkdate(dt)).strftime('%d. %b %Y').decode('utf-8')

def datetimefilter(dt):
    return _local_tz(mkdate(dt))

def datecode(dt):
    return dt.strftime('%Y-%m-%d').decode('utf-8')

def datetimecode(dt):
    return dt.strftime('%Y-%m-%dT%H:%M:%SZ').decode('utf-8')

def rst(value):
    return publish_parts(value, writer_name='html',
            settings_overrides={'initial_header_level':2})['body']

def mkdate(v):
    if isinstance(v, datetime.datetime):
        return v
    return datetime.datetime.utcfromtimestamp(float(v)).replace(tzinfo=pytz.utc)

def urlencode(v):
{'fraction_non_alphanumeric': 0.14965986394557823, 'fraction_numerical': 0.002834467120181406, 'mean_word_length': 5.107266435986159, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6782888', 'n_tokens_mistral': 626, 'n_tokens_neox': 618, 'n_words': 117}