<commit_before>"""
byceps.util.datetime.format
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Date/time formatting.

:Copyright: 2006-2019 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from datetime import date, datetime, time, timedelta
from typing import Union


DateOrDateTime = Union[date, datetime]


def format_custom(dt: DateOrDateTime, pattern: str) -> str:
    return dt.strftime(pattern)


def format_day_smart(d: DateOrDateTime) -> str:
    if isinstance(d, datetime):
        d = d.date()

    today = date.today()
    if d == today:
        return 'heute'
    elif d == (today - timedelta(days=1)):
        return 'gestern'
    else:
        return None


def format_date_iso(d: date) -> str:
    return d.strftime('%Y-%m-%d')


def format_date_short(d: date, *, smart: bool=True) -> str:
    return (smart and format_day_smart(d)) or d.strftime('%d.%m.%Y')


def format_date_long(d: date, *, smart: bool=True) -> str:
    return (smart and format_day_smart(d)) or d.strftime('%A, %d. %B %Y')


def format_datetime_iso(dt: datetime) -> str:
    return dt.strftime('%Y-%m-%dT%H:%M:%S')


def format_datetime_short(dt: datetime, *, smart: bool=True) -> str:
    date_string = format_date_short(dt.date(), smart=smart)
    time_string = format_time(dt.time())

    return '{}, {}'.format(date_string, time_string)


def format_datetime_long(dt: datetime, *, smart: bool=True) -> str:
    date_string = format_date_long(dt.date(), smart=smart)
    time_string = format_time(dt.time())

    return '{}, {}'.format(date_string, time_string)


def format_time(t: time) -> str:
    return t.strftime('%H:%M Uhr')<commit_msg>Turn `byceps.util.datetime.format` into a private helper function<commit_after>"""
byceps.util.datetime.format
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Date/time formatting.

:Copyright: 2006-2019 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from datetime import date, datetime, time, timedelta
from typing import Union


DateOrDateTime = Union[date, datetime]


def format_custom(dt: DateOrDateTime, pattern: str) -> str:
    return dt.strftime(pattern)


def format_date_iso(d: date) -> str:
    return d.strftime('%Y-%m-%d')


def format_date_short(d: date, *, smart: bool=True) -> str:
    return (smart and _format_date_smart(d)) or d.strftime('%d.%m.%Y')


def format_date_long(d: date, *, smart: bool=True) -> str:
    return (smart and _format_date_smart(d)) or d.strftime('%A, %d. %B %Y')


def format_datetime_iso(dt: datetime) -> str:
    return dt.strftime('%Y-%m-%dT%H:%M:%S')


def format_datetime_short(dt: datetime, *, smart: bool=True) -> str:
    date_string = format_date_short(dt.date(), smart=smart)
    time_string = format_time(dt.time())

    return '{}, {}'.format(date_string, time_string)


def format_datetime_long(dt: datetime, *, smart: bool=True) -> str:
    date_string = format_date_long(dt.date(), smart=smart)
    time_string = format_time(dt.time())

    return '{}, {}'.format(date_string, time_string)


def format_time(t: time) -> str:
    return t.strftime('%H:%M Uhr')


# helpers


def _format_date_smart(d: DateOrDateTime) -> str:
    if isinstance(d, datetime):
        d = d.date()

    today = date.today()
    if d == today:
        return 'heute'
    elif d == (today - timedelta(days=1)):
        return 'gestern'
    else:
        return None
{'fraction_non_alphanumeric': 0.16857314870559903, 'fraction_numerical': 0.005418422636965683, 'mean_word_length': 4.004518072289157, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '1184319', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1128, 'n_words': 276}