<commit_before>import locale
import time
import datetime
import urllib
import jinja2

from django.utils.text import truncate_words as _truncate_words
from django.utils.timezone import utc
from django.db.utils import IntegrityError

from jingo import register
from sorl.thumbnail import get_thumbnail

from airmozilla.base.utils import html_to_text


@register.filter
def js_date(dt, format='ddd, MMM D, YYYY, h:mma UTCZZ', enable_timeago=True,
            autoupdate=False):
    """ Python datetime to a time tag with JS Date.parse-parseable format. """
    dt_date = dt.strftime('%m/%d/%Y')
    dt_time = dt.strftime('%H:%M')
    dt_tz = dt.tzname() or 'UTC'
    formatted_datetime = ' '.join([dt_date, dt_time, dt_tz])
    class_ = 'timeago ' if enable_timeago else ''
    if autoupdate:
        class_ += 'autoupdate '
    return jinja2.Markup('<time datetime="%s" class="%sjstime"'
                         ' data-format="%s">%s</time>'
                         % (dt.isoformat(), class_,
                            format, formatted_datetime))


@register.function
def date_now():
    """The current date in UTC."""
    return datetime.datetime.utcnow().replace(tzinfo=utc, microsecond=0)


@register.function
def short_desc(event, words=25, strip_html=False):
    """Takes an event object and returns a shortened description."""
    if event.short_description:
        return event.short_description<commit_msg>fixes bug 909365 - Editing is broken because of events that don't have an end date<commit_after>import locale
import time
import datetime
import urllib
import jinja2

from django.utils.text import truncate_words as _truncate_words
from django.utils.timezone import utc
from django.db.utils import IntegrityError

from jingo import register
from sorl.thumbnail import get_thumbnail

from airmozilla.base.utils import html_to_text


@register.filter
def js_date(dt, format='ddd, MMM D, YYYY, h:mma UTCZZ', enable_timeago=True,
            autoupdate=False):
    """ Python datetime to a time tag with JS Date.parse-parseable format. """
    if dt is None:
        return ''
    dt_date = dt.strftime('%m/%d/%Y')
    dt_time = dt.strftime('%H:%M')
    dt_tz = dt.tzname() or 'UTC'
    formatted_datetime = ' '.join([dt_date, dt_time, dt_tz])
    class_ = 'timeago ' if enable_timeago else ''
    if autoupdate:
        class_ += 'autoupdate '
    return jinja2.Markup('<time datetime="%s" class="%sjstime"'
                         ' data-format="%s">%s</time>'
                         % (dt.isoformat(), class_,
                            format, formatted_datetime))


@register.function
def date_now():
    """The current date in UTC."""
    return datetime.datetime.utcnow().replace(tzinfo=utc, microsecond=0)


@register.function
def short_desc(event, words=25, strip_html=False):
    """Takes an event object and returns a shortened description."""
    if event.short_description:
        return event.short_description
{'fraction_non_alphanumeric': 0.11046906866077498, 'fraction_numerical': 0.005438477226376614, 'mean_word_length': 3.3089311859443633, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4090008', 'n_tokens_mistral': 933, 'n_tokens_neox': 897, 'n_words': 250}