本文整理匯總了Python中dateparser.languages.detection.ExactLanguages.parse方法的典型用法代碼示例。如果您正苦於以下問題:Python ExactLanguages.parse方法的具體用法?Python ExactLanguages.parse怎麽用?Python ExactLanguages.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dateparser.languages.detection.ExactLanguages
的用法示例。
在下文中一共展示了ExactLanguages.parse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_parse_date_in_exact_language
# 需要導入模塊: from dateparser.languages.detection import ExactLanguages [as 別名]
# 或者: from dateparser.languages.detection.ExactLanguages import parse [as 別名]
def test_parse_date_in_exact_language(self):
date_fixtures = [
(u'13 Ago, 2014', datetime(2014, 8, 13)),
(u'13 Septiembre, 2014', datetime(2014, 9, 13)),
(u'13/03/2014', datetime(2014, 3, 13)),
# TODO: make the following test pass
# in this case, it should have detected spanish as the
# language, and so it should use d/m/Y instead of d/m/Y
# (u'11/03/2014', datetime(2014, 3, 11)),
]
spanish = LanguageDataLoader().get_language('es')
parser = ExactLanguages([spanish])
for date_string, correct_date in date_fixtures:
parsed_date = parser.parse(date_string, None)
self.assertEqual(correct_date.date(), parsed_date.date())
with self.assertRaisesRegexp(ValueError, 'Invalid date'):
portuguese_date = u'13 Setembro, 2014'
parser.parse(portuguese_date, None)