<commit_before>from dateutil.relativedelta import relativedelta
from datetime import datetime, timedelta
import pytz


tz = pytz.timezone('America/New_York')
tz_utc = pytz.timezone('UTC')

DATE_PARTS = ['year', 'month', 'day']
TIME_PARTS = ['hour', 'minute', 'second', 'microsecond']


def enum(**enums):
    return type('Enum', (), enums)


WEEK_DAY = enum( MONDAY=0, TUESDAY=1, WEDNESDAY=2, THRUSDAY=3, \
                  FRIDAY=4, SATURDAY=5, SUNDAY=6)
   

def eastern_date_as_utc(year, **kwargs):

    dateparts = {'year': year, 'tzinfo': tz}
    dateparts.update(kwargs)

    date = datetime(**dateparts)

    return date.astimezone(tz_utc)


def get_date_for_week(year, week):
    if week < 1:
        raise ValueError('Week must be greater than 0')

    dt = datetime(**{
            'year': year,
            'month': 1,
            'day': 1
        })

    while dt.weekday() != WEEK_DAY.FRIDAY:
        dt += timedelta(1)

    week -= 1
    dt += timedelta(7 * week)

    return dt


def calc_week(dt):
    
    dt = get_next_weekdate(dt, direction='down')
    year = dt.year

    count = 0
    while dt.year == year:
        count += 1
        dt -= timedelta(days=7)

    return (year, count) # the week year might be different


def clear(dt, parts=TIME_PARTS):
    replace_dict = {}

    for p in parts:
        replace_dict[p] = date_norm_map.get(p)

    return dt.replace(**replace_dict)


def get_next_weekdate(dt, direction='up'):<commit_msg>switch week calculation to merge up instead of down<commit_after>from dateutil.relativedelta import relativedelta
from datetime import datetime, timedelta
import pytz


tz = pytz.timezone('America/New_York')
tz_utc = pytz.timezone('UTC')

DATE_PARTS = ['year', 'month', 'day']
TIME_PARTS = ['hour', 'minute', 'second', 'microsecond']


def enum(**enums):
    return type('Enum', (), enums)


WEEK_DAY = enum( MONDAY=0, TUESDAY=1, WEDNESDAY=2, THRUSDAY=3, \
                  FRIDAY=4, SATURDAY=5, SUNDAY=6)


def eastern_date_as_utc(year, **kwargs):

    dateparts = {'year': year, 'tzinfo': tz}
    dateparts.update(kwargs)

    date = datetime(**dateparts)

    return date.astimezone(tz_utc)


def get_date_for_week(year, week):
    if week < 1:
        raise ValueError('Week must be greater than 0')

    dt = datetime(**{
            'year': year,
            'month': 1,
            'day': 1
        })

    while dt.weekday() != WEEK_DAY.FRIDAY:
        dt += timedelta(1)

    week -= 1
    dt += timedelta(7 * week)

    return dt


def calc_week(dt):
    
    dt = get_next_weekdate(dt, direction='up')
    year = dt.year

    count = 0
    while dt.year == year:
        count += 1
        dt -= timedelta(days=7)

    return (year, count) # the week year might be different


def clear(dt, parts=TIME_PARTS):
    replace_dict = {}

    for p in parts:
        replace_dict[p] = date_norm_map.get(p)

    return dt.replace(**replace_dict)


def get_next_weekdate(dt, direction='up'):
{'fraction_non_alphanumeric': 0.135948596550558, 'fraction_numerical': 0.011498140006763611, 'mean_word_length': 2.8717277486910993, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5984051', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1024, 'n_words': 255}