示例#1
0
    def test_that_it_returns_same_day_for_first_of_month_midnight(self):
        some_datetime = datetime.datetime(
            year=2013, month=11, day=1, hour=0, minute=0, second=0,
            microsecond=0)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(some_datetime))
示例#2
0
    def test_that_it_returns_same_day_for_first_of_month_midnight(self):
        some_datetime = datetime.datetime(
            year=2013, month=11, day=1, hour=0, minute=0, second=0,
            microsecond=0)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(some_datetime))
示例#3
0
    def test_that_it_truncates_the_time_part(self):
        some_datetime = d(2013, 5, 7, 10, 12, 13)

        start = MONTH.start(some_datetime)

        assert_that(start.hour, is_(0))
        assert_that(start.minute, is_(0))
        assert_that(start.second, is_(0))
        assert_that(start.microsecond, is_(0))
示例#4
0
    def test_that_it_truncates_the_time_part(self):
        some_datetime = d(2013, 5, 7, 10, 12, 13)

        start = MONTH.start(some_datetime)

        assert_that(start.hour, is_(0))
        assert_that(start.minute, is_(0))
        assert_that(start.second, is_(0))
        assert_that(start.microsecond, is_(0))
示例#5
0
    def __init__(self, data):
        result = validate_record_data(data)
        if not result.is_valid:
            raise ValidationError(result.message)

        self.data = data
        self.meta = {}

        if "_timestamp" in self.data:
            self.meta['_week_start_at'] = WEEK.start(self.data['_timestamp'])
            self.meta['_month_start_at'] = MONTH.start(self.data['_timestamp'])
def datum(name=None, version=None, place=None, age=None, stamp=None, count=1):
    result = {"_count": count}
    if name is not None:
        result['name'] = name
    if version is not None:
        result['version'] = version
    if place is not None:
        result['place'] = place
    if age is not None:
        result['age'] = age
    if stamp is not None:
        result['_timestamp'] = stamp
        result['_week_start_at'] = WEEK.start(stamp)
        result['_month_start_at'] = MONTH.start(stamp)
    return result
示例#7
0
def datum(name=None, place=None, age=None, stamp=None, count=1):
    result = {
        "_count": count
    }
    if name is not None:
        result['name'] = name
    if place is not None:
        result['place'] = place
    if age is not None:
        result['age'] = age
    if stamp is not None:
        result['_timestamp'] = stamp
        result['_week_start_at'] = WEEK.start(stamp)
        result['_month_start_at'] = MONTH.start(stamp)
    return result
示例#8
0
    def test_that_it_returns_same_day_for_first_of_month(self):
        some_datetime = d(2013, 12, 1, 12, 32, 34)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(d(2013, 12, 1)))
示例#9
0
    def test_that_it_returns_first_of_current_month_for_midmonth(self):
        some_datetime = d(2013, 4, 9)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(d(2013, 4, 1)))
示例#10
0
    def test_that_it_returns_same_day_for_first_of_month(self):
        some_datetime = d(2013, 12, 1, 12, 32, 34)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(d(2013, 12, 1)))
示例#11
0
    def test_that_it_returns_first_of_current_month_for_midmonth(self):
        some_datetime = d(2013, 4, 9)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(d(2013, 4, 1)))