# Path: aerofiles/igc/patterns.py
# DATE = re.compile('^([0-3][0-9])([0-1][0-9])([0-9]{2})$')
# TIME = re.compile('^([0-2][0-9])([0-5][0-9])([0-5][0-9])$')
# DATETIME = re.compile('^([0-3][0-9])([0-1][0-9])([0-9]{2})'
#                       '([0-2][0-9])([0-5][0-9])([0-5][0-9])$')
# THREE_LETTER_CODE = re.compile('^[A-Z0-9]{3}$')
# MANUFACTURER_CODE = THREE_LETTER_CODE
# LOGGER_ID = THREE_LETTER_CODE
# EXTENSION_CODE = THREE_LETTER_CODE


import datetime
from aerofiles.igc import patterns



class Writer:
    """
    A writer for the IGC flight log file format.
    """

    REQUIRED_HEADERS = [
        'manufacturer_code',
        'logger_id',
        'date',
        'logger_type',
        'gps_receiver',
    ]

    def __init__(self, fp=None):
        self.fp = fp
        self.fix_extensions = None
        self.k_record_extensions = None

    def format_date(self, date):
        if isinstance(date, datetime.datetime):
            date = date.date()

        if isinstance(date, datetime.date):
            date = date.strftime('%d%m%y')


# Path: aerofiles/igc/patterns.py
# DATE = re.compile('^([0-3][0-9])([0-1][0-9])([0-9]{2})$')
# TIME = re.compile('^([0-2][0-9])([0-5][0-9])([0-5][0-9])$')
# DATETIME = re.compile('^([0-3][0-9])([0-1][0-9])([0-9]{2})'
#                       '([0-2][0-9])([0-5][0-9])([0-5][0-9])$')
# THREE_LETTER_CODE = re.compile('^[A-Z0-9]{3}$')
# MANUFACTURER_CODE = THREE_LETTER_CODE
# LOGGER_ID = THREE_LETTER_CODE
# EXTENSION_CODE = THREE_LETTER_CODE


# Path: aerofiles/igc/writer.py
import datetime
from aerofiles.igc import patterns




class Writer:
    """
    A writer for the IGC flight log file format.
    """

    REQUIRED_HEADERS = [
        'manufacturer_code',
        'logger_id',
        'date',
        'logger_type',
        'gps_receiver',
    ]

    def __init__(self, fp=None):
        self.fp = fp
        self.fix_extensions = None
        self.k_record_extensions = None

    def format_date(self, date):
        if isinstance(date, datetime.datetime):
            date = date.date()

        if isinstance(date, datetime.date):
            date = date.strftime('%d%m%y')


        if not patterns.DATE.match(date):