当前位置: 首页>>代码示例>>Python>>正文


Python timesince.timeuntil方法代码示例

本文整理汇总了Python中django.utils.timesince.timeuntil方法的典型用法代码示例。如果您正苦于以下问题:Python timesince.timeuntil方法的具体用法?Python timesince.timeuntil怎么用?Python timesince.timeuntil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.utils.timesince的用法示例。


在下文中一共展示了timesince.timeuntil方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: remaining_time

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def remaining_time(self, object):
        return timeuntil(object.expires_at) 
开发者ID:mvantellingen,项目名称:django-healthchecks,代码行数:4,代码来源:admin.py

示例2: timeuntil_filter

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def timeuntil_filter(value, arg=None):
    """Formats a date as the time until that date (i.e. "4 days, 6 hours")."""
    if not value:
        return ''
    try:
        return timeuntil(value, arg)
    except (ValueError, TypeError):
        return ''


###################
# LOGIC           #
################### 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:15,代码来源:defaultfilters.py

示例3: humanize_seconds

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def humanize_seconds(seconds):
    now = timezone.now()
    return timeuntil(now + timedelta(seconds=seconds), now) 
开发者ID:rapidpro,项目名称:casepro,代码行数:5,代码来源:__init__.py

示例4: timeuntil_filter

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def timeuntil_filter(value, arg=None):
    """Format a date as the time until that date (i.e. "4 days, 6 hours")."""
    if not value:
        return ''
    try:
        return timeuntil(value, arg)
    except (ValueError, TypeError):
        return ''


###################
# LOGIC           #
################### 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:15,代码来源:defaultfilters.py

示例5: timeuntil_filter

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def timeuntil_filter(value, arg=None):
    """Formats a date as the time until that date (i.e. "4 days, 6 hours")."""
    if not value:
        return ''
    try:
        return timeuntil(value, arg)
    except (ValueError, TypeError):
        return ''

###################
# LOGIC           #
################### 
开发者ID:blackye,项目名称:luscan-devel,代码行数:14,代码来源:defaultfilters.py

示例6: test_different_timezones

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def test_different_timezones(self):
        """ When using two different timezones. """
        now = datetime.datetime.now()
        now_tz = timezone.make_aware(now, timezone.get_default_timezone())
        now_tz_i = timezone.localtime(now_tz, timezone.get_fixed_timezone(195))

        self.assertEqual(timesince(now), '0\xa0minutes')
        self.assertEqual(timesince(now_tz), '0\xa0minutes')
        self.assertEqual(timesince(now_tz_i), '0\xa0minutes')
        self.assertEqual(timesince(now_tz, now_tz_i), '0\xa0minutes')
        self.assertEqual(timeuntil(now), '0\xa0minutes')
        self.assertEqual(timeuntil(now_tz), '0\xa0minutes')
        self.assertEqual(timeuntil(now_tz_i), '0\xa0minutes')
        self.assertEqual(timeuntil(now_tz, now_tz_i), '0\xa0minutes') 
开发者ID:nesdis,项目名称:djongo,代码行数:16,代码来源:test_timesince.py

示例7: test_date_objects

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def test_date_objects(self):
        """ Both timesince and timeuntil should work on date objects (#17937). """
        today = datetime.date.today()
        self.assertEqual(timesince(today + self.oneday), '0\xa0minutes')
        self.assertEqual(timeuntil(today - self.oneday), '0\xa0minutes') 
开发者ID:nesdis,项目名称:djongo,代码行数:7,代码来源:test_timesince.py

示例8: test_both_date_objects

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def test_both_date_objects(self):
        """ Timesince should work with both date objects (#9672) """
        today = datetime.date.today()
        self.assertEqual(timeuntil(today + self.oneday, today), '1\xa0day')
        self.assertEqual(timeuntil(today - self.oneday, today), '0\xa0minutes')
        self.assertEqual(timeuntil(today + self.oneweek, today), '1\xa0week') 
开发者ID:nesdis,项目名称:djongo,代码行数:8,代码来源:test_timesince.py

示例9: test_leap_year

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def test_leap_year(self):
        start_date = datetime.date(2016, 12, 25)
        self.assertEqual(timeuntil(start_date + self.oneweek, start_date), '1\xa0week')
        self.assertEqual(timesince(start_date, start_date + self.oneweek), '1\xa0week') 
开发者ID:nesdis,项目名称:djongo,代码行数:6,代码来源:test_timesince.py

示例10: test_leap_year_new_years_eve

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def test_leap_year_new_years_eve(self):
        t = datetime.date(2016, 12, 31)
        now = datetime.datetime(2016, 12, 31, 18, 0, 0)
        self.assertEqual(timesince(t + self.oneday, now), '0\xa0minutes')
        self.assertEqual(timeuntil(t - self.oneday, now), '0\xa0minutes') 
开发者ID:nesdis,项目名称:djongo,代码行数:7,代码来源:test_timesince.py

示例11: test_thousand_years_ago

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def test_thousand_years_ago(self):
        t = datetime.datetime(1007, 8, 14, 13, 46, 0)
        self.assertEqual(timesince(t, self.t), '1000\xa0years')
        self.assertEqual(timeuntil(self.t, t), '1000\xa0years') 
开发者ID:nesdis,项目名称:djongo,代码行数:6,代码来源:test_timesince.py

示例12: test_naive_datetime_with_tzinfo_attribute

# 需要导入模块: from django.utils import timesince [as 别名]
# 或者: from django.utils.timesince import timeuntil [as 别名]
def test_naive_datetime_with_tzinfo_attribute(self):
        class naive(datetime.tzinfo):
            def utcoffset(self, dt):
                return None
        future = datetime.datetime(2080, 1, 1, tzinfo=naive())
        self.assertEqual(timesince(future), '0\xa0minutes')
        past = datetime.datetime(1980, 1, 1, tzinfo=naive())
        self.assertEqual(timeuntil(past), '0\xa0minutes') 
开发者ID:nesdis,项目名称:djongo,代码行数:10,代码来源:test_timesince.py


注:本文中的django.utils.timesince.timeuntil方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。