def test_cast_from(self): for d in self.dates: self.assertEqual(BusinessDate.from_date(d.to_date()), d) self.assertEqual(BusinessDate.from_businessdate(d), d) self.assertEqual(BusinessDate.from_excel(d.to_excel()), d) self.assertEqual(BusinessDate.from_ordinal(d.to_ordinal()), d) self.assertEqual(BusinessDate.from_string(d.to_string()), d) self.assertEqual(BusinessDate.from_ymd(*d.to_ymd()), d)
def _cast_to_dates(self, *in_date): ret = list() r = None for d in in_date: if isinstance(d, BusinessDate): r = d else: if isinstance(d, (datetime.date, datetime.datetime)): r = BusinessDate.from_date(d) elif isinstance(d, BusinessPeriod): r = d.to_businessdate(self.origin) ret.append(r) return ret