<commit_before>import re
import math
from datetime import datetime

KEYWORD_ENTRY_RUNNING = 'running'
DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
DATE_SPEC_RE = "((?:\d{4})-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}|running)"
ENTRY_MATCHER_RE = DATE_SPEC_RE + '\s+' + DATE_SPEC_RE + '(?::?$|:\s+(.*))'
ENTRY_MATCHER = re.compile(ENTRY_MATCHER_RE)

split_words = re.compile('\s+').split

def dumps_date(d):
    """
    Encodes the given datetime object for usage in the internal
    representation.

    @param datetime.datetime d
    @return str
    """
    return d.strftime(DATE_FORMAT)

def loads_date(d):
    """
    Decodes a datetime object from the given internal string
    representation

    @param str d
    """
    return datetime.strptime(d, DATE_FORMAT)

def format_date(d):
    """
    Formats the given datetime object for better human readability

    @param datetime.datetime d
    @return str
    """
    age = datetime.now().date() - d.date()
    date = d.strftime("%Y-%m-%d")
    if age.days == 0:
        date = 'today'
    elif age.days == 1:
        date = 'yesterday'
    elif age.days < 6:
        date = '%d days ago' % age.days

    time = d.strftime("%H:%M")
    return "%s %s" % (date, time)

def format_timedelta(d):
    """
    Formats the given timedelta object for good human readability

    @param timedelta d
    @return str
    """
    seconds = d.seconds
    minutes = math.floor(seconds / 60.)
    seconds -= minutes * 60
    hours = math.floor(minutes / 60.)
    minutes -= hours * 60

    ret = ""
    if hours == 1:
        ret += "one hour "
    elif hours > 1:
        ret += "%d hours " % hours

    if minutes:
        ret += "%d min " % minutes

    if seconds or not ret:
        ret += "%d sec " % seconds
<commit_msg>properly handle full days<commit_after>import re
import math
from datetime import datetime

KEYWORD_ENTRY_RUNNING = 'running'
DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
DATE_SPEC_RE = "((?:\d{4})-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}|running)"
ENTRY_MATCHER_RE = DATE_SPEC_RE + '\s+' + DATE_SPEC_RE + '(?::?$|:\s+(.*))'
ENTRY_MATCHER = re.compile(ENTRY_MATCHER_RE)

split_words = re.compile('\s+').split

def dumps_date(d):
    """
    Encodes the given datetime object for usage in the internal
    representation.

    @param datetime.datetime d
    @return str
    """
    return d.strftime(DATE_FORMAT)

def loads_date(d):
    """
    Decodes a datetime object from the given internal string
    representation

    @param str d
    """
    return datetime.strptime(d, DATE_FORMAT)

def format_date(d):
    """
    Formats the given datetime object for better human readability

    @param datetime.datetime d
    @return str
    """
    age = datetime.now().date() - d.date()
    date = d.strftime("%Y-%m-%d")
    if age.days == 0:
        date = 'today'
    elif age.days == 1:
        date = 'yesterday'
    elif age.days < 6:
        date = '%d days ago' % age.days

    time = d.strftime("%H:%M")
    return "%s %s" % (date, time)

def format_timedelta(d):
    """
    Formats the given timedelta object for good human readability

    @param timedelta d
    @return str
    """
    seconds = d.seconds
    minutes = math.floor(seconds / 60.)
    seconds -= minutes * 60
    hours = math.floor(minutes / 60.)
    minutes -= hours * 60
    days = d.days

    ret = ""
    if days > 0:
        ret += "%d day(s) " % days
    elif hours == 1:
        ret += "one hour "
    elif hours > 1:
        ret += "%d hours " % hours

    if minutes:
        ret += "%d min " % minutes

    if seconds or not ret:
        ret += "%d sec " % seconds

{'fraction_non_alphanumeric': 0.1475684740078256, 'fraction_numerical': 0.010899944102850754, 'mean_word_length': 2.498533724340176, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '4462994', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1197, 'n_words': 346}