# Path: notifications_utils/countries/data.py
# class Postage:
#     UK = 'united-kingdom'
#     FIRST = 'first'
#     SECOND = 'second'
#     EUROPE = 'europe'
#     REST_OF_WORLD = 'rest-of-world'
# 
# Path: notifications_utils/timezones.py
# def convert_utc_to_bst(utc_dt):
#     """
#     Takes a naive UTC datetime and returns a naive London datetime
#     """
#     return pytz.utc.localize(utc_dt).astimezone(local_timezone).replace(tzinfo=None)
# 
# def utc_string_to_aware_gmt_datetime(date):
#     """
#     Date can either be a string, naive UTC datetime or an aware UTC datetime
#     Returns an aware London datetime, essentially the time you'd see on your clock
#     """
#     if not isinstance(date, datetime):
#         date = parser.parse(date)
# 
#     forced_utc = date.replace(tzinfo=pytz.utc)
#     return forced_utc.astimezone(local_timezone)


from collections import namedtuple
from datetime import datetime, time, timedelta
from govuk_bank_holidays.bank_holidays import BankHolidays
from notifications_utils.countries.data import Postage
from notifications_utils.timezones import (
    convert_utc_to_bst,
    utc_string_to_aware_gmt_datetime,
)
import pytz
    if days_to_deliver == 1:
        return next_day
    return get_delivery_day(next_day, days_to_deliver=(days_to_deliver - 1))


def get_min_and_max_days_in_transit(postage):
    return {
        # first class post is printed earlier in the day, so will
        # actually transit on the printing day, and be delivered the next
        # day, so effectively spends no full days in transit
        'first': (0, 0),
        'second': (1, 2),
        Postage.EUROPE: (3, 5),
        Postage.REST_OF_WORLD: (5, 7),
    }[postage]


def get_earliest_and_latest_delivery(print_day, postage):
    for days_to_transit in get_min_and_max_days_in_transit(postage):
        yield get_delivery_day(print_day, days_to_deliver=1 + days_to_transit)


def get_letter_timings(upload_time, postage):

    LetterTimings = namedtuple(
        'LetterTimings',
        'printed_by, is_printed, earliest_delivery, latest_delivery'
    )

    # shift anything after 5:30pm to the next day

# Path: notifications_utils/countries/data.py
# class Postage:
#     UK = 'united-kingdom'
#     FIRST = 'first'
#     SECOND = 'second'
#     EUROPE = 'europe'
#     REST_OF_WORLD = 'rest-of-world'
# 
# Path: notifications_utils/timezones.py
# def convert_utc_to_bst(utc_dt):
#     """
#     Takes a naive UTC datetime and returns a naive London datetime
#     """
#     return pytz.utc.localize(utc_dt).astimezone(local_timezone).replace(tzinfo=None)
# 
# def utc_string_to_aware_gmt_datetime(date):
#     """
#     Date can either be a string, naive UTC datetime or an aware UTC datetime
#     Returns an aware London datetime, essentially the time you'd see on your clock
#     """
#     if not isinstance(date, datetime):
#         date = parser.parse(date)
# 
#     forced_utc = date.replace(tzinfo=pytz.utc)
#     return forced_utc.astimezone(local_timezone)


# Path: notifications_utils/letter_timings.py
from collections import namedtuple
from datetime import datetime, time, timedelta
from govuk_bank_holidays.bank_holidays import BankHolidays
from notifications_utils.countries.data import Postage
from notifications_utils.timezones import (
    convert_utc_to_bst,
    utc_string_to_aware_gmt_datetime,
)
import pytz

    if days_to_deliver == 1:
        return next_day
    return get_delivery_day(next_day, days_to_deliver=(days_to_deliver - 1))


def get_min_and_max_days_in_transit(postage):
    return {
        # first class post is printed earlier in the day, so will
        # actually transit on the printing day, and be delivered the next
        # day, so effectively spends no full days in transit
        'first': (0, 0),
        'second': (1, 2),
        Postage.EUROPE: (3, 5),
        Postage.REST_OF_WORLD: (5, 7),
    }[postage]


def get_earliest_and_latest_delivery(print_day, postage):
    for days_to_transit in get_min_and_max_days_in_transit(postage):
        yield get_delivery_day(print_day, days_to_deliver=1 + days_to_transit)


def get_letter_timings(upload_time, postage):

    LetterTimings = namedtuple(
        'LetterTimings',
        'printed_by, is_printed, earliest_delivery, latest_delivery'
    )

    # shift anything after 5:30pm to the next day

    processing_day = utc_string_to_aware_gmt_datetime(upload_time) + timedelta(hours=6, minutes=30)