本文整理汇总了Python中faker.providers.date_time.Provider.date_time_between方法的典型用法代码示例。如果您正苦于以下问题:Python Provider.date_time_between方法的具体用法?Python Provider.date_time_between怎么用?Python Provider.date_time_between使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类faker.providers.date_time.Provider
的用法示例。
在下文中一共展示了Provider.date_time_between方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: firefox
# 需要导入模块: from faker.providers.date_time import Provider [as 别名]
# 或者: from faker.providers.date_time.Provider import date_time_between [as 别名]
def firefox(cls):
ver = (
'Gecko/{0} Firefox/{1}.0'.format(
DatetimeProvider.date_time_between(
datetime(2011, 1, 1)), random.randint(4, 15)),
'Gecko/{0} Firefox/3.6.{1}'.format(
DatetimeProvider.date_time_between(
datetime(2010, 1, 1)), random.randint(1, 20)),
'Gecko/{0} Firefox/3.8'.format(
DatetimeProvider.date_time_between(
datetime(2010, 1, 1)), ),
)
tmplt_win = '({0}; {1}; rv:1.9.{2}.20) {3}'
tmplt_lin = '({0}; rv:1.9.{1}.20) {2}'
tmplt_mac = '({0}; rv:1.9.{1}.20) {2}'
platforms = (
tmplt_win.format(cls.windows_platform_token(),
cls.random_element(cls.langs),
random.randint(0, 2),
random.choice(ver)),
tmplt_lin.format(cls.linux_platform_token(),
random.randint(5, 7),
random.choice(ver)),
tmplt_mac.format(cls.mac_platform_token(),
random.randint(2, 6),
random.choice(ver)),
)
return 'Mozilla/5.0 ' + cls.random_element(platforms)
示例2: credit_card_expire
# 需要导入模块: from faker.providers.date_time import Provider [as 别名]
# 或者: from faker.providers.date_time.Provider import date_time_between [as 别名]
def credit_card_expire(cls, start='now', end='+10y', date_format='%m/%y'):
expire_date = DateTimeProvider.date_time_between(start, end)
return expire_date.strftime(date_format)