コード例 #1
0
ファイル: test_dates.py プロジェクト: CarlFK/dabo
	def test_getDateFromString(self):
		formats = ["ISO8601", "YYYYMMDD", "YYMMDD", "MMDD"]
		tests = ["0503", "20060503", "2006-05-03", "060503"]
		expected_date = datetime.date(year, 5, 3)

		tests = ((["ISO8601"], "%s-05-03" % year_str4, expected_date),
		         (["YYYYMMDD"], "%s0503" % year_str4, expected_date),
		         (["YYMMDD"], "%s0503" % year_str2, expected_date),
		         (["MMDD"], "0503", expected_date),
		         (["ISO8601"], "%s05-03" % year_str4, None),)
		for test in tests:
			self.assertEqual(dates.getDateFromString(test[1], test[0]), test[2])
コード例 #2
0
    def test_getDateFromString(self):
        formats = ["ISO8601", "YYYYMMDD", "YYMMDD", "MMDD"]
        tests = ["0503", "20060503", "2006-05-03", "060503"]
        expected_date = datetime.date(year, 05, 03)

        tests = (
            (["ISO8601"], "%s-05-03" % year_str4, expected_date),
            (["YYYYMMDD"], "%s0503" % year_str4, expected_date),
            (["YYMMDD"], "%s0503" % year_str2, expected_date),
            (["MMDD"], "0503", expected_date),
            (["ISO8601"], "%s05-03" % year_str4, None),
        )
        for test in tests:
            self.assertEqual(dates.getDateFromString(test[1], test[0]),
                             test[2])
コード例 #3
0
ファイル: test_dates.py プロジェクト: CarlFK/dabo
	def test_getStringFromDate(self):
		test_str = "2006-05-03"
		test_date = dates.getDateFromString(test_str)
		dabo.dateFormat = "%Y-%m-%d"
		self.assertEqual(dates.getStringFromDate(test_date), test_str)
コード例 #4
0
 def test_getStringFromDate(self):
     test_str = "2006-05-03"
     test_date = dates.getDateFromString(test_str)
     dabo.dateFormat = "%Y-%m-%d"
     self.assertEqual(dates.getStringFromDate(test_date), test_str)