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


Python DateTime.strftime方法代码示例

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


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

示例1: get_birthdaysToday

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import strftime [as 别名]
    def get_birthdaysToday(self, type_filter):
        results = []
        if type_filter == 1:
            date_start = date.today().strftime('%Y-%m-%d')
            date_end = date.today().strftime('%Y-%m-%d')

            results = ModelsDadosFuncdetails().get_FuncBirthdays(date_start,date_end)

        elif type_filter == 7:
            now = DateTime()
            dow = now.dow()
            date_start = (now - dow).strftime('%Y-%m-%d')
            date_end = (now - dow + 6).strftime('%Y-%m-%d')

            results = ModelsDadosFuncdetails().get_FuncBirthdays(date_start,date_end)

        elif type_filter == 30:
            now = DateTime()

            dia = calendar.monthrange(now.year(),now.month())[1]
            date_start = now.strftime('%Y-%m-1')
            date_end = now.strftime('%Y-%m-'+str(dia))

            results = ModelsDadosFuncdetails().get_FuncBirthdays(date_start,date_end)

        elif type_filter == 'prox':
            results = ModelsDadosFuncdetails().get_FuncBirthdays('','','proximo')

        if results:
            return results #results[:int(quant)]
        else:
            return []
开发者ID:vindula,项目名称:vindula.myvindula,代码行数:34,代码来源:myvindula.py

示例2: is_import_allowed

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import strftime [as 别名]
 def is_import_allowed(self):
     # Checking if auto-import enabled in bika setup. Return False if not.
     interval = self.portal.bika_setup.getAutoImportInterval()
     if interval < 10:
         return False
     caches = self.portal.listFolderContents(contentFilter={
                                             "portal_type": 'BikaCache'})
     cache = None
     for c in caches:
         if c and c.getKey() == 'LastAutoImport':
             cache = c
     now = DateTime.strftime(DateTime(), '%Y-%m-%d %H:%M:%S')
     if not cache:
         _id = self.portal.invokeFactory("BikaCache", id=tmpID(),
                                         Key='LastAutoImport',
                                         Value=now)
         item = self.portal[_id]
         item.markCreationFlag()
         return True
     else:
         last_import = cache.getValue()
         diff = datetime.now() - datetime.strptime(last_import,
                                                   '%Y-%m-%d %H:%M:%S')
         if diff.seconds < interval * 60:
             return False
         cache.edit(Value=now)
         return True
开发者ID:xispa,项目名称:bika.lims,代码行数:29,代码来源:resultsimport.py

示例3: format_log_data

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import strftime [as 别名]
 def format_log_data(self, instrument, interface, result, filename):
     log = DateTime.strftime(DateTime(), '%Y-%m-%d %H:%M:%S')
     log += ' - ' + instrument
     log += ' - ' + interface
     log += ' - ' + filename
     r = ''.join(result)
     log += ' - ' + r
     return log
开发者ID:xispa,项目名称:bika.lims,代码行数:10,代码来源:resultsimport.py

示例4: report

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import strftime [as 别名]
 def report(self, current, *args, **kw):
     if current > 0:
         if current % self._steps == 0:
             seconds_so_far = time.time() - self._start
             seconds_to_go = (seconds_so_far / current *
                              (self._max - current))
             end = DateTime(time.time() + seconds_to_go)
             self.output('%d/%d (%.2f%%) Estimated termination: %s' % \
                         (current, self._max, (100.0 * current / self._max),
                         end.strftime('%Y/%m/%d %H:%M:%Sh')))
开发者ID:Andyvs,项目名称:TrackMonthlyExpenses,代码行数:12,代码来源:ProgressHandler.py

示例5: event_to_view_obj

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import strftime [as 别名]
 def event_to_view_obj(self, event):
     local_start = DateTime(event.start)
     local_start_str = local_start.strftime('%d/%m/%Y')
     local_end = DateTime(event.end)
     local_end_str = local_end.strftime('%d/%m/%Y')
     is_same_day = local_start_str == local_end_str
     return dict(
         class_li='' if is_same_day else 'multidate',
         class_a='' if is_same_day else 'multidate-before',
         date_start=local_start_str,
         date_end=local_end_str,
         day_start=int(local_start.strftime('%d')),
         day_end=int(local_end.strftime('%d')),
         is_multidate=not is_same_day,
         month_start=self.get_month_name(local_start.strftime('%m')),
         month_start_abbr=self.get_month_name(
             local_start.strftime('%m'), month_format='a'),
         month_end=self.get_month_name(local_end.strftime('%m')),
         month_end_abbr=self.get_month_name(
             local_end.strftime('%m'), month_format='a'),
         title=event.Title,
         url=event.absolute_url(),
         )
开发者ID:UPCnet,项目名称:genweb.theme,代码行数:25,代码来源:esdeveniments.py

示例6: test_unicode_zuite_result

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import strftime [as 别名]
    def test_unicode_zuite_result(self):
        from DateTime.DateTime import DateTime
        from Products.Zelenium.zuite import ZuiteResults
        from OFS.Image import File

        zuite = self._makeOne().__of__( self.root )
        # simulating zuite.postResults to create ZuiteResults object
        completed = DateTime('2010-05-30')
        result_id = 'result_%s' % completed.strftime( '%Y%m%d_%H%M%S' )
        zresults = ZuiteResults(result_id).__of__(zuite)
        zresults.manage_changeProperties(completed=completed,
                                         passed=False,
                                         time_secs=0,
                                         tests_passed=0,
                                         tests_failed=0,
                                         commands_passed=0,
                                         commands_failed=0,
                                         commands_with_errors=0,
                                         user_agent='unknown',
                                         remote_addr='unknown',
                                         http_host='unknown',
                                         server_software='unknown',
                                         product_info=zuite._listProductInfo())
        zresults._setObject( 'suite.html'
                           , File( 'suite.html'
                                 , 'Test Suite'
                                 , CONTENT_suite_html
                                 , 'text/html'
                                 )
                           )

        zresults._setObject( 'testTable.1'
                           , File( 'testTable.1'
                                 , 'Test case: testTable.1'
                                 , CONTENT_testTable_1
                                 , 'text/html'
                                 )
                           )
        self.failUnless( u'azértï' in zresults.index_html() )
开发者ID:joehelmstetler,项目名称:erp5,代码行数:41,代码来源:test_zuite.py

示例7: result

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import strftime [as 别名]
    def result(self, date=None,
               use_ampm=False,
               starting_year=None,
               ending_year=None,
               future_years=None,
               minute_step=5):
        """Returns a dict with date information.
        """
        ptool = getToolByName(self.context, 'portal_properties')

        site_props = ptool.site_properties

        # Get the date format from the locale
        context = aq_inner(self.context)
        portal_state = getMultiAdapter((context, self.request), name=u'plone_portal_state')

        dates = portal_state.locale().dates

        timepattern = dates.getFormatter('time').getPattern()
        if 'a' in timepattern:
             use_ampm = True
        month_names = dates.getFormatter('date').calendar.months

        # 'id' is what shows up.  December for month 12. 
        # 'value' is the value for the form.
        # 'selected' is whether or not it is selected.

        default=0
        years=[]
        days=[]
        months=[]
        hours=[]
        minutes=[]
        ampm=[]
        now=DateTime()

        if isinstance(date, basestring):
            date=date.strip()
            if not date:
                date=None
            else:
                # Please see datecomponents.txt for an explanation of 
                # the next few lines. Also see #11423
                dateParts = date.split(" ")
                dateParts[0] = dateParts[0].replace("-", "/")
                date=' '.join(dateParts)

        if date is None:
            date=now
            default=1
        elif not isinstance(date, DateTime):
            try:
                date=DateTime(date)
            except (TypeError, DateTimeError):
                date=now
                default=1

        # Anything above PLONE_CEILING should be PLONE_CEILING
        if date.greaterThan(PLONE_CEILING):
            date = PLONE_CEILING

        # Represent the date in the local timezone
        local_zone = date.localZone(localtime(date.timeTime()))
        date = date.toZone(local_zone)

        # Get portal year range
        if starting_year is None:
            min_year = site_props.getProperty('calendar_starting_year', 1999)
        else:
            min_year = int(starting_year)
        if ending_year is None:
            if future_years is None:
                max_year = site_props.getProperty('calendar_future_years_available', 5) + now.year()
            else:
                max_year = int(future_years) + now.year()
        else:
            max_year = int(ending_year)

        # keeps the existing date if it's out of range
        if not default:
            if min_year > date.year():
                min_year = date.year()
            if max_year < date.year():
                max_year = date.year()

        year=int(date.strftime('%Y'))

        if default:
            years.append({'id': '--', 'value': '0000', 'selected': 1})
        else:
            years.append({'id': '--', 'value': '0000', 'selected': None})

        for x in range(min_year, max_year+1):
            d={'id': x, 'value': x, 'selected': None}
            if x==year and not default:
                d['selected']=1
            years.append(d)

        month=int(date.strftime('%m'))

#.........这里部分代码省略.........
开发者ID:rochecompaan,项目名称:plone.app.form,代码行数:103,代码来源:datecomponents.py

示例8: result

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import strftime [as 别名]

#.........这里部分代码省略.........
                min_year = date.year()
            if max_year < date.year():
                max_year = date.year()

        year = date.year()

        if default:
            years.append({'id': '--', 'value': '0000', 'selected': 1})
        else:
            years.append({'id': '--', 'value': '0000', 'selected': None})

        for x in range(min_year, max_year+1):
            d = {'id': x, 'value': x, 'selected': None}
            if x == year and not default:
                d['selected'] = 1
            years.append(d)

        month = date.month()

        if default:
            months.append({'id': '--', 'value': '00', 'selected': 1, 'title': '--'})
        else:
            months.append({'id': '--', 'value': '00', 'selected': None, 'title': '--'})

        for x in range(1, 13):
            d = {'id': ENGLISH_MONTH_NAMES[x], 'value': '%02d' % x, 'selected': None}
            if x == month and not default:
                d['selected'] = 1
            d['title'] = month_names[x][0]
            months.append(d)

        day = date.day()

        if default:
            days.append({'id': '--', 'value': '00', 'selected': 1})
        else:
            days.append({'id': '--', 'value': '00', 'selected': None})

        for x in range(1, 32):
            d = {'id': x, 'value': '%02d' % x, 'selected': None}
            if x == day and not default:
                d['selected'] = 1
            days.append(d)

        if use_ampm:
            hours_range = [12] + range(1, 12)
            hour_default = '12'
            hour = int(date.h_12())
        else:
            hours_range = range(0, 24)
            hour_default = '00'
            hour = int(date.h_24())
        
        if default:
            hours.append({'id': '--', 'value': hour_default, 'selected': 1})
        else:
            hours.append({'id': '--', 'value': hour_default, 'selected': None})

        for x in hours_range:
            d = {'id': '%02d' % x, 'value': '%02d' % x, 'selected': None}
            if x == hour and not default:
                d['selected'] = 1
            hours.append(d)

        if default:
            minutes.append({'id': '--', 'value': '00', 'selected': 1})
        else:
            minutes.append({'id': '--', 'value': '00', 'selected': None})

        minute = date.minute()

        if minute_step is None:
            minute_step = 5

        if minute + minute_step >= 60:
            # edge case. see doctest for explanation
            minute = 60 - minute_step

        for x in range(0, 60, minute_step):
            d = {'id': '%02d' % x, 'value': '%02d' % x, 'selected': None}
            if (x == minute or minute < x < minute + minute_step) and not default:
                d['selected'] = 1
            minutes.append(d)

        if use_ampm:
            p = date.strftime('%p')

            if default:
                ampm.append({'id': '--', 'value': 'AM', 'selected': 1})
            else:
                ampm.append({'id': '--', 'value': 'AM', 'selected': None})

            for x in ('AM', 'PM'):
                d = {'id': x, 'value': x, 'selected': None}
                if x == p and not default:
                    d['selected'] = 1
                ampm.append(d)

        return {'years': years, 'months': months, 'days': days,
                'hours': hours, 'minutes': minutes, 'ampm': ampm}
开发者ID:Goldmund-Wyldebeast-Wunderliebe,项目名称:Products.Archetypes,代码行数:104,代码来源:datecomponents.py

示例9: postResults

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import strftime [as 别名]
    def postResults(self, REQUEST):
        """ Record the results of a test run.

        o Create a folder with properties representing the summary results,
          and files containing the suite and the individual test runs.

        o REQUEST will have the following form fields:

          result -- one of "failed" or "passed"

          totalTime -- time in floating point seconds for the run

          numTestPasses -- count of test runs which passed

          numTestFailures -- count of test runs which failed

          numCommandPasses -- count of commands which passed

          numCommandFailures -- count of commands which failed

          numCommandErrors -- count of commands raising non-assert errors

          suite -- Colorized HTML of the suite table

          testTable.<n> -- Colorized HTML of each test run
        """
        completed = DateTime()
        result_id = 'result_%s' % completed.strftime( '%Y%m%d_%H%M%S' )
        self._setObject( result_id, ZuiteResults( result_id ) )
        result = self._getOb( result_id )
        rfg = REQUEST.form.get
        reg = REQUEST.environ.get

        result._updateProperty( 'completed'
                              , completed
                              )

        result._updateProperty( 'passed'
                              , rfg( 'result' ).lower() == 'passed'
                              )

        result._updateProperty( 'time_secs'
                              , float( rfg( 'totalTime', 0 ) )
                              )

        result._updateProperty( 'tests_passed'
                              , int( rfg( 'numTestPasses', 0 ) )
                              )

        result._updateProperty( 'tests_failed'
                              , int( rfg( 'numTestFailures', 0 ) )
                              )

        result._updateProperty( 'commands_passed'
                              , int( rfg( 'numCommandPasses', 0 ) )
                              )

        result._updateProperty( 'commands_failed'
                              , int( rfg( 'numCommandFailures', 0 ) )
                              )

        result._updateProperty( 'commands_with_errors'
                              , int( rfg( 'numCommandErrors', 0 ) )
                              )

        result._updateProperty( 'user_agent'
                              , reg( 'HTTP_USER_AGENT', 'unknown' )
                              )

        result._updateProperty( 'remote_addr'
                              , reg( 'REMOTE_ADDR', 'unknown' )
                              )

        result._updateProperty( 'http_host'
                              , reg( 'HTTP_HOST', 'unknown' )
                              )

        result._updateProperty( 'server_software'
                              , reg( 'SERVER_SOFTWARE', 'unknown' )
                              )

        result._updateProperty( 'product_info'
                              , self._listProductInfo()
                              )

        result._setObject( 'suite.html'
                         , File( 'suite.html'
                               , 'Test Suite'
                               , unquote( rfg( 'suite' ) )
                               , 'text/html'
                               )
                         )

        test_ids = [ x for x in REQUEST.form.keys()
                        if x.startswith( 'testTable' ) ]
        test_ids.sort()

        for test_id in test_ids:
            body = unquote( rfg( test_id ) )
            result._setObject( test_id
#.........这里部分代码省略.........
开发者ID:MarkTang,项目名称:erp5,代码行数:103,代码来源:zuite.py

示例10: postResults

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import strftime [as 别名]
    def postResults(self, REQUEST):
        """ Record the results of a test run.

        o Create a folder with properties representing the summary results,
          and files containing the suite and the individual test runs.

        o REQUEST will have the following form fields:

          result -- one of "failed" or "passed"

          totalTime -- time in floating point seconds for the run

          numTestPasses -- count of test runs which passed

          numTestFailures -- count of test runs which failed

          numCommandPasses -- count of commands which passed

          numCommandFailures -- count of commands which failed

          numCommandErrors -- count of commands raising non-assert errors

          suite -- Colorized HTML of the suite table

          testTable.<n> -- Colorized HTML of each test run
        """
        completed = DateTime()
        result_id = "result_%s" % completed.strftime("%Y%m%d_%H%M%S.%f")
        self._setObject(result_id, ZuiteResults(result_id))
        result = self._getOb(result_id)
        rfg = REQUEST.form.get
        reg = REQUEST.environ.get

        result._updateProperty("completed", completed)

        result._updateProperty("passed", rfg("result").lower() == "passed")

        result._updateProperty("finished", rfg("finished").lower() == "true")

        result._updateProperty("time_secs", float(rfg("totalTime", 0)))

        result._updateProperty("tests_passed", int(rfg("numTestPasses", 0)))

        result._updateProperty("tests_failed", int(rfg("numTestFailures", 0)))

        result._updateProperty("commands_passed", int(rfg("numCommandPasses", 0)))

        result._updateProperty("commands_failed", int(rfg("numCommandFailures", 0)))

        result._updateProperty("commands_with_errors", int(rfg("numCommandErrors", 0)))

        result._updateProperty("user_agent", reg("HTTP_USER_AGENT", "unknown"))

        result._updateProperty("remote_addr", reg("REMOTE_ADDR", "unknown"))

        result._updateProperty("http_host", reg("HTTP_HOST", "unknown"))

        result._updateProperty("server_software", reg("SERVER_SOFTWARE", "unknown"))

        result._updateProperty("product_info", self._listProductInfo())

        result._setObject("suite.html", File("suite.html", "Test Suite", unquote(rfg("suite")), "text/html"))

        test_ids = [x for x in REQUEST.form.keys() if x.startswith("testTable")]
        test_ids.sort()

        for test_id in test_ids:
            body = unquote(rfg(test_id))
            result._setObject(test_id, File(test_id, "Test case: %s" % test_id, body, "text/html"))
            testcase = result._getOb(test_id)

            # XXX:  this is silly, but we have no other metadata.
            testcase._setProperty("passed", _PINK_BACKGROUND.search(body) is None, "boolean")
开发者ID:bhuvanaurora,项目名称:erp5,代码行数:75,代码来源:zuite.py

示例11: localized_time

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import strftime [as 别名]
 def localized_time(self, date):
     local_date = DateTime(date)
     return local_date.strftime('%Y-%m-%d %X')
开发者ID:UPCnet,项目名称:genweb.theme,代码行数:5,代码来源:overrides.py


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