def test_custom_date_string(self):
        custom_format = "%y-%b-%d"

        parsed_date_1 = to_date("16-Mar-03", custom_format)
        parsed_date_2 = to_date("16-Aug-13", custom_format)

        self.assertTrue(isinstance(parsed_date_1, datetime.date))
        self.assertTrue(isinstance(parsed_date_2, datetime.date))
示例#2
0
    def test_custom_date_string(self):
        custom_format = "%y-%b-%d"

        parsed_date_1 = to_date("16-Mar-03", custom_format)
        parsed_date_2 = to_date("16-Aug-13", custom_format)

        self.assertTrue(isinstance(parsed_date_1, datetime.date))
        self.assertTrue(isinstance(parsed_date_2, datetime.date))
示例#3
0
def _build_exercise(metadata):
    return {
        "start_date": to_date(metadata["ref_p_start_date"]),
        "end_date": to_date(metadata["ref_p_end_date"]),
        "employment_date": to_date(metadata["employment_date"]),
        "return_by": to_date(metadata["return_by"]),
        "region_code": metadata["region_code"],
    }
def _build_survey_meta(metadata):
    return {
        "return_by": to_date(metadata["return_by"]),
        "start_date":  to_date(metadata["ref_p_start_date"]),
        "end_date": to_date(metadata["ref_p_end_date"]),
        "employment_date": to_date(metadata["employment_date"]),
        "region_code": metadata["region_code"] if 'region_code' in metadata else None,
        "period_str": metadata["period_str"],
        "eq_id": metadata["eq_id"],
        "collection_id": metadata["collection_exercise_sid"],
        "form_type": metadata["form_type"],
    }
def _build_exercise():
    """
    Build the exercise data from the survey metadata
    """
    metadata = get_metadata(current_user)

    return {
        "start_date": to_date(metadata["ref_p_start_date"]),
        "end_date": to_date(metadata["ref_p_end_date"]),
        "employment_date": to_date(metadata["employment_date"]),
        "return_by": to_date(metadata["return_by"]),
    }
    def _format_date(input_date_string):
        formatted_date = to_date(input_date_string)

        if formatted_date:
            return '{dt.day} {dt:%B} {dt.year}'.format(dt=formatted_date)
        return None
 def test_parse_valid_date(self):
     self.assertTrue(isinstance(to_date("2016-04-01"), datetime.date))
     self.assertTrue(isinstance(to_date("2016-09-09"), datetime.date))
    def test_parse_empty_date(self):
        date_str = None

        parsed_date = to_date(date_str)

        self.assertEquals(parsed_date, None)
 def test_parse_invalid_date(self):
     self.assertEquals(to_date("2016-Mar-03"), None)
     self.assertEquals(to_date("a-random-string"), None)
示例#10
0
 def test_parse_valid_date(self):
     self.assertTrue(isinstance(to_date("2016-04-01"), datetime.date))
     self.assertTrue(isinstance(to_date("2016-09-09"), datetime.date))
示例#11
0
    def test_parse_empty_date(self):
        date_str = None

        parsed_date = to_date(date_str)

        self.assertEqual(parsed_date, None)
示例#12
0
 def test_parse_invalid_date(self):
     self.assertEqual(to_date("2016-Mar-03"), None)
     self.assertEqual(to_date("a-random-string"), None)