# Path: Date.py
# class Date(object):
#     def __init__(self, from_float=None):
#         if from_float is not None:
#             if isinstance(from_float, float):
#                 self._value = Date._from_float(from_float)  # a datetime.date
#             else:
#                 print 'arg from_float %s is of type %s, not float' % (from_float, type(from_float))
#                 assert False, 'construction error'
#         else:
#             print 'bad construction of Date'
#             assert False, 'construct via Data(from_float=<float value>)'
# 
#     def as_datetime_date(self):
#         'return value as a datetime.date'
#         return self._value  # for now, the value is stored as a datetime.date
# 
#     @staticmethod
#     def _from_float(x):
#         'return a datetime.date'
#         assert isinstance(x, float), x
#         assert 0 < x <= 99999999, x
#         year = int(x / 10000)
#         month_day = x - year * 10000
#         month = int(month_day / 100)
#         day = int(month_day - month * 100)
#         result = datetime.date(year, month, day)
#         return result


import collections
import datetime
import unittest
from Date import Date
            return date
        elif isinstance(date, float):
            return Date(from_float=date).as_datetime_date()
        else:
            raise ValueError('unsupported date type: %s' % date)

    def canonical_apn(apn):
        'return an long'
        value = long(apn)
        if value != apn:
            raise ValueError('loss of precision: %s' % apn)
        return value

    return TransactionId(
        sale_date=canonical_sale_date(transaction_id.sale_date),
        apn=canonical_apn(transaction_id.apn)
    )


class TestTransactionId(unittest.TestCase):
    def test_equality(self):
        'equality is based on field value, not object identity'
        x = TransactionId(1, 23)
        y = TransactionId(1, 23)
        z = TransactionId(2, 23)
        self.assertEqual(x, y)
        self.assertNotEqual(x, z)

    def test_canonical(self):
        x = TransactionId(sale_date=20070124.0, apn=2425019009L)

# Path: Date.py
# class Date(object):
#     def __init__(self, from_float=None):
#         if from_float is not None:
#             if isinstance(from_float, float):
#                 self._value = Date._from_float(from_float)  # a datetime.date
#             else:
#                 print 'arg from_float %s is of type %s, not float' % (from_float, type(from_float))
#                 assert False, 'construction error'
#         else:
#             print 'bad construction of Date'
#             assert False, 'construct via Data(from_float=<float value>)'
# 
#     def as_datetime_date(self):
#         'return value as a datetime.date'
#         return self._value  # for now, the value is stored as a datetime.date
# 
#     @staticmethod
#     def _from_float(x):
#         'return a datetime.date'
#         assert isinstance(x, float), x
#         assert 0 < x <= 99999999, x
#         year = int(x / 10000)
#         month_day = x - year * 10000
#         month = int(month_day / 100)
#         day = int(month_day - month * 100)
#         result = datetime.date(year, month, day)
#         return result


# Path: TransactionId.py
import collections
import datetime
import unittest
from Date import Date

            return date
        elif isinstance(date, float):
            return Date(from_float=date).as_datetime_date()
        else:
            raise ValueError('unsupported date type: %s' % date)

    def canonical_apn(apn):
        'return an long'
        value = long(apn)
        if value != apn:
            raise ValueError('loss of precision: %s' % apn)
        return value

    return TransactionId(
        sale_date=canonical_sale_date(transaction_id.sale_date),
        apn=canonical_apn(transaction_id.apn)
    )


class TestTransactionId(unittest.TestCase):
    def test_equality(self):
        'equality is based on field value, not object identity'
        x = TransactionId(1, 23)
        y = TransactionId(1, 23)
        z = TransactionId(2, 23)
        self.assertEqual(x, y)
        self.assertNotEqual(x, z)

    def test_canonical(self):
        x = TransactionId(sale_date=20070124.0, apn=2425019009L)

        y = canonical(x)