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


Python DateTime.latestTime方法代码示例

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


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

示例1: getCriteriaItems

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
    def getCriteriaItems(self):
        """Return a sequence of items to be used to build the catalog query.
        """
        if self.value is not None:
            field = self.Field()
            value = self.Value()

            # Negate the value for 'old' days
            if self.getDateRange() == '-':
                value = -value

            date = DateTime() + value
            current_date = DateTime()

            operation = self.getOperation()
            if operation == 'within_day':
                date_range = ( date.earliestTime(), date.latestTime() )
                return ( ( field, {'query': date_range, 'range': 'min:max'} ), )
            elif operation == 'more':
                if value != 0:
                    range_op = (self.getDateRange() == '-' and 'max') or 'min'
                    return ( ( field, {'query': date.earliestTime(), 'range': range_op} ), )
                else:
                    return ( ( field, {'query': date, 'range': 'min'} ), )
            elif operation == 'less':
                if value != 0:
                    date_range = (self.getDateRange() == '-' and
                                  (date.earliestTime(), current_date)
                                  ) or (current_date, date.latestTime())
                    return ( ( field, {'query': date_range, 'range': 'min:max'} ), )
                else:
                    return ( ( field, {'query': date, 'range': 'max'} ), )
        else:
            return ()
开发者ID:nacho22martin,项目名称:tesis,代码行数:36,代码来源:date.py

示例2: myhours

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
    def myhours(self):
        """Gets the content."""
        etool = getToolByName(self, TIMETOOLNAME)
        portal = self.portal
        user = getSecurityManager().getUser().getUserName()
        now = DateTime()
        start = now.earliestTime() - 6
        end = now.latestTime()
        hours = list(etool.getHours(node=portal, start=start, end=end,
                                    REQUEST=None, Creator=user))

        def earliestStart(hour):
            start = hour.start.earliestTime()
            # Ensure a clean date in the server timezone
            return DateTime(start.Date())

        hours.sort(key=earliestStart)
        by_date = dict((k, tuple(v))
                       for (k, v) in groupby(hours, earliestStart))
        results = []
        for i in range(7):
            date = start + i
            hours = by_date.get(date, ())
            results.append(dict(date=date,
                                sum=etool.countHours(hours)))
        return results
开发者ID:Blaastolen,项目名称:intranett,代码行数:28,代码来源:hourslastweekportlet.py

示例3: get_query

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
    def get_query(self):
        query = {
            'object_provides': 'ftw.news.interfaces.INews',
            'sort_on': 'start',
            'sort_order': 'reverse',
            'path': '/'.join(self.context.getPhysicalPath())
        }

        datestring = self.request.get('archive')
        if datestring:
            try:
                start = DateTime(datestring)
            except DateTime.interfaces.SyntaxError:
                raise
            end = DateTime('{0}/{1}/{2}'.format(
                start.year() + start.month() / 12,
                start.month() % 12 + 1,
                1)
            ) - 1
            query['start'] = {
                'query': (start.earliestTime(), end.latestTime()),
                'range': 'minmax',
            }

        return query
开发者ID:4teamwork,项目名称:ftw.news,代码行数:27,代码来源:news_listing.py

示例4: getEndOfMonth

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
def getEndOfMonth(year, month):
    """Get the last second of the last day of this month

    First some normal months.

    >>> getEndOfMonth(2007, 1)
    DateTime('2007/01/31 23:59:59 GMT+1')
    >>> getEndOfMonth(2007, 4)
    DateTime('2007/04/30 23:59:59 GMT+2')

    Of course February needs extra testing.

    >>> getEndOfMonth(2007, 2)
    DateTime('2007/02/28 23:59:59 GMT+1')

    2008 is a leap year.

    >>> getEndOfMonth(2008, 2)
    DateTime('2008/02/29 23:59:59 GMT+1')

    """
    if month in (1, 3, 5, 7, 8, 10, 12):
        day = 31
    elif month == 2:
        if DateTime(year, 1, 1).isLeapYear():
            day = 29
        else:
            day = 28
    else:
        day = 30
    return DateTime.latestTime(DateTime(year, month, day))
开发者ID:zestsoftware,项目名称:Products.eXtremeManagement,代码行数:33,代码来源:utils.py

示例5: _today

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
def _today(context, row):
    now = DateTime()
    start_date = now.earliestTime()
    end_date = now.latestTime()
    row = Row(index=row.index,
              operator=row.operator,
              values=(start_date, end_date))
    return _between(context, row)
开发者ID:,项目名称:,代码行数:10,代码来源:

示例6: getStartAndEndTimes

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
 def getStartAndEndTimes(self,year,month,monthNextYear,monthNext):
     "return the start and end times that we will search over"
     start = DateTime('%s %s %s' % (year, month, 1)).earliestTime()
     #To find the endpoint we find the first day of the next month, go back one day and find
     #the Latest time that takes place on that day
     end = DateTime('%s %s %s' % (monthNextYear,monthNext, 1)) -1
     end = end.latestTime()
     return start,end
开发者ID:Immudzen,项目名称:CompoundDoc,代码行数:10,代码来源:eventcalendar.py

示例7: test__today

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
 def test__today(self):
     now = DateTime()
     expected_dates = [now.earliestTime(), now.latestTime()]
     expected = {'modified': {'query': expected_dates, 'range': 'minmax'}}
     data = Row(index='modified',
               operator='_today',
               values=expected_dates)
     parsed = queryparser._today(MockSite(), data)
     self.assertEqual(parsed, expected)
开发者ID:cryu,项目名称:plone.app.querystring,代码行数:11,代码来源:testQueryParser.py

示例8: test__moreThanRelativeDate

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
 def test__moreThanRelativeDate(self):
     days = 2
     now = DateTime()
     mydate = now - days
     expected_dates = [mydate.earliestTime(), now.latestTime()]
     expected = {'modified': {'query': expected_dates, 'range': 'minmax'}}
     data = Row(index='modified',
               operator='_moreThanRelativeDate',
               values=days)
     parsed = queryparser._moreThanRelativeDate(MockSite(), data)
     self.assertEqual(parsed, expected)
开发者ID:cryu,项目名称:plone.app.querystring,代码行数:13,代码来源:testQueryParser.py

示例9: extend_query_by_date

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
def extend_query_by_date(query, datestring, date_field):
    try:
        start = DateTime(datestring)
    except dtSytaxError:
        return query
    end = DateTime('%s/%s/%s' % (start.year() + start.month() / 12,
                                 start.month() % 12 + 1, 1))
    end = end - 1
    query[date_field] = {'query': (start.earliestTime(),
                                    end.latestTime()),
                          'range': 'minmax'}
    return query
开发者ID:4teamwork,项目名称:ftw.contentpage,代码行数:14,代码来源:baselisting.py

示例10: _moreThanRelativeDate

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
def _moreThanRelativeDate(context, row):
    """ "Between now and N days ago." """
    # INFO: Values is the number of days
    try:
        values = int(row.values)
    except ValueError:
        values = 0
    now = DateTime()
    start_date = now - values
    start_date = start_date.earliestTime()
    end_date = now.latestTime()
    row = Row(index=row.index, operator=row.operator, values=(start_date, end_date))
    return _between(context, row)
开发者ID:headnet,项目名称:plone.app.querystring,代码行数:15,代码来源:queryparser.py

示例11: getBlogItemsByDate

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
 def getBlogItemsByDate(self, date, sort=1, pub_date_filter=1):
     """ return only those with pub_date within today """
     start_y, start_m, start_d = date.year(), date.month(), date.day()
     d = DateTime(start_y,start_m,start_d)
     r = (d.earliestTime(), d.latestTime())
     search = {'meta_type':BLOGITEM_METATYPE,
               'pub_date': {'query':r, 'range':'min:max'},
               'sort_on':'pub_date',
               'sort_order':'reverse',
               }
     blogitems = []
     for brain in self.getCatalog().searchResults(search):
         blogitems.append(brain.getObject())
     return blogitems
开发者ID:peterbe,项目名称:Peterbecom,代码行数:16,代码来源:BlogContainer.py

示例12: getBounds

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
def getBounds(date, value):
    """
        Obtain two bound dates, based on the current date and value used
        
        >>> from collective.periodcriterion.criteria import getBounds
        >>> from DateTime import DateTime
        >>> getBounds(DateTime('2011/02/14'), 'today')
        (DateTime('2011/02/14 00:00:00 GMT+1'), DateTime('2011/02/14 23:59:59 GMT+1'))

        Hour is ignored completly
        
        >>> getBounds(DateTime('2011/02/14 23:59:59'), 'today')
        (DateTime('2011/02/14 00:00:00 GMT+1'), DateTime('2011/02/14 23:59:59 GMT+1'))
        
        Check month

        >>> getBounds(DateTime('2011/02/14'), 'this_month')
        (DateTime('2011/02/01 00:00:00 GMT+1'), DateTime('2011/02/28 23:59:59 GMT+1'))
        >>> getBounds(DateTime('2011/02/01'), 'this_month')
        (DateTime('2011/02/01 00:00:00 GMT+1'), DateTime('2011/02/28 23:59:59 GMT+1'))
        >>> getBounds(DateTime('2011/02/28'), 'this_month')
        (DateTime('2011/02/01 00:00:00 GMT+1'), DateTime('2011/02/28 23:59:59 GMT+1'))
        >>> getBounds(DateTime('2011/12/25'), 'this_month')
        (DateTime('2011/12/01 00:00:00 GMT+1'), DateTime('2011/12/31 23:59:59 GMT+1'))

        Check year

        >>> getBounds(DateTime('2011/02/02'), 'this_year')
        (DateTime('2011/01/01 00:00:00 GMT+1'), DateTime('2011/12/31 23:59:59 GMT+1'))


    """
    if value=='today':
        today = DateTime(date.Date())
        return (today.earliestTime(), today.latestTime())
    if value=='this_month':
        month_start = DateTime('%d/%02d/01' % (date.year(), date.month()) )
        nextMonth = date.month()+1
        year = date.year()
        if nextMonth==13:
            year+=1
            nextMonth = 1
        return (month_start, (DateTime('%d/%02d/01' % (year, nextMonth)).latestTime())-1 )
    if value=='this_year':
        return (DateTime('%d/01/01' % date.year()).earliestTime(), DateTime('%d/12/31' % date.year()).latestTime())            
    return ()
开发者ID:RedTurtle,项目名称:collective.periodcriterion,代码行数:48,代码来源:criteria.py

示例13: DateToPeriod

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
def DateToPeriod(period="week", date=None):
    """Return the start and end dates for a time period defined by a
    length and a date.
    """

    if date is None:
        date=DateTime()

    if period=="day":
        start=date.earliestTime()
        end=date.latestTime()
    elif period=="week":
        start=(date-((date.dow()+6)%7)).earliestTime()
        end=(start+6).latestTime()
    elif period=="month":
        start=(date-(date.day()-1)).earliestTime()
        end=(start+31).latestTime()
        if end.day()<28:
            end-=end.day()
    else:
        raise ValueError("undefined period")

    return (start, end)
开发者ID:Blaastolen,项目名称:intranett,代码行数:25,代码来源:worklog.py

示例14: __call__

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
    def __call__(self):
        """ Get all the Blogentries and return the listingview template.

        It check if the request has some filtering parameters:
        -archive
        -searchable_text
        -getCategoryUids
        -tag
        """

        # TODO: Refactor me. This method is too long!

        context = aq_inner(self.context)
        query = {}
        self.filters = []
        catalog = getToolByName(context, "portal_catalog")

        if self.request.form.get("archive"):
            datestr = self.request.form.get("archive")
            try:
                start = DateTime(datestr)
            except DateTime.SyntaxError:
                start = DateTime(DateTime().strftime("%Y/%m/01"))
            end = DateTime("%s/%s/%s" % (start.year() + start.month() / 12, start.month() % 12 + 1, 1))
            end = end - 1
            query["created"] = {"query": (start.earliestTime(), end.latestTime()), "range": "minmax"}
            month_msgid = "month_%s" % start.strftime("%b").lower()
            month = translate(month_msgid, domain="plonelocales", context=self.request)
            self.filters.append("%s %s" % (month, start.strftime("%Y")))
        if self.request.form.get("getCategoryUids"):
            uid = self.request.form.get("getCategoryUids")
            category = catalog(UID=uid)[0]
            category_title = category.Title
            if category:
                category_obj = category.getObject()
                if base_hasattr(category_obj, "getTranslations"):
                    uid = [c.UID() for c in category_obj.getTranslations(review_state=False).values()]
                    translated = category_obj.getTranslation()
                    # If there are no translations getTranslation returns None
                    if translated:
                        category_title = translated.Title()
            query["getCategoryUids"] = uid
            category = catalog(UID=uid)[0]
            self.filters.append(category_title)
        if self.request.form.get("searchable_text"):
            query["SearchableText"] = self.request.get("searchable_text")
            self.filters.append(query["SearchableText"])
        if self.request.form.get("tag"):
            query["tags"] = self.request.form.get("tag").decode("utf-8")
            self.filters.append(query["tags"])
        if context.portal_type != "Blog":
            querystring = self.query_string()
            if querystring:
                querystring = "?%s" % querystring
            return self.request.response.redirect(aq_parent(context).absolute_url() + querystring)

        query["sort_on"] = "created"
        query["sort_order"] = "reverse"
        query["portal_type"] = "BlogEntry"
        # show all entries from all languages
        # XXX make this configurable
        if not base_hasattr(context, "getTranslations"):
            self.entries = context.getFolderContents(contentFilter=query)
        else:
            translations = context.getTranslations().values()
            paths = ["/".join(tr[0].getPhysicalPath()) for tr in translations]
            query["path"] = paths
            query["Language"] = "all"
            self.entries = catalog(query)

        b_start = self.request.form.get("b_start", 0)
        self.batch = Batch(self.entries, 5, b_start)

        return self.template()
开发者ID:4teamwork,项目名称:ftw.blog,代码行数:76,代码来源:blog.py

示例15: __call__

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import latestTime [as 别名]
    def __call__(self):
        """ Get all the Blogentries and return the listingview template.

        It check if the request has some filtering parameters:
        -archive
        -searchable_text
        -getCategoryUids
        -tag
        """

        # TODO: Refactor me. This method is too long!

        context = aq_inner(self.context)
        query = {}
        self.filters = []
        catalog = getToolByName(context, 'portal_catalog')

        if self.request.form.get('archive'):
            datestr = self.request.form.get('archive')
            try:
                start = DateTime(datestr)
            except DateTime.SyntaxError:
                start = DateTime(DateTime().strftime("%Y/%m/01"))
            end = DateTime('%s/%s/%s' % (start.year() + start.month() / 12,
                                         start.month() % 12 + 1, 1))
            end = end - 1
            query['created'] = {'query': (start.earliestTime(),
                                          end.latestTime()),
                                'range': 'minmax'}
            month_msgid = 'month_%s' % start.strftime("%b").lower()
            month = translate(month_msgid, domain='plonelocales',
                              context=self.request)
            self.filters.append("%s %s" % (month, start.strftime('%Y')))
        if self.request.form.get('getCategoryUids'):
            uid = self.request.form.get('getCategoryUids')
            category = catalog(UID=uid)[0]
            category_title = category.Title
            if category:
                category_obj = category.getObject()
                if base_hasattr(category_obj, 'getTranslations'):
                    uid = [c.UID() for c in category_obj.getTranslations(
                            review_state=False).values()]
                    translated = category_obj.getTranslation()
                    # If there are no translations getTranslation returns None
                    if translated:
                        category_title = translated.Title()
            query['getCategoryUids'] = uid
            category = catalog(UID=uid)[0]
            self.filters.append(category_title)
        if self.request.form.get('searchable_text'):
            query['SearchableText'] = self.request.get('searchable_text')
            self.filters.append(query['SearchableText'])
        if self.request.form.get('tag'):
            query['tags'] = self.request.form.get('tag').decode('utf-8')
            self.filters.append(query['tags'])
        if context.portal_type != 'Blog':
            querystring = self.query_string()
            if querystring:
                querystring = '?%s' % querystring
            return self.request.response.redirect(
                aq_parent(context).absolute_url() + querystring)

        query['sort_on'] = 'effective'
        query['sort_order'] = 'reverse'
        query['portal_type'] = 'BlogEntry'
        # show all entries from all languages
        # XXX make this configurable
        if not base_hasattr(context, 'getTranslations'):
            self.entries = context.getFolderContents(contentFilter=query)
        else:
            translations = context.getTranslations().values()
            paths = ['/'.join(tr[0].getPhysicalPath()) for tr in translations]
            query['path'] = paths
            query['Language'] = 'all'
            self.entries = catalog(query)

        b_start = self.request.form.get('b_start', 0)
        self.batch = Batch(self.entries, 5, b_start)

        return self.template()
开发者ID:pcdummy,项目名称:ftw.blog,代码行数:82,代码来源:blog.py


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