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


Python DateTime.timeTime方法代码示例

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


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

示例1: _getNextDay

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
  def _getNextDay(self, date, timezone):
    if timezone is not None:
      new_date = DateTime(date.timeTime() + 86400.0, timezone)
    else:
      new_date = DateTime(date.timeTime() + 86400.0)

    # Due to daylight savings, 24 hours later does not always mean that
    # it's next day.
    while new_date.day() == date.day():
      if timezone is not None:
        new_date = DateTime(new_date.timeTime() + 3600.0, timezone)
      else:
        new_date = DateTime(new_date.timeTime() + 3600.0)
    return DateTime(new_date.year(), new_date.month(), new_date.day(),
            0, 0, 0, timezone)
开发者ID:bhuvanaurora,项目名称:erp5,代码行数:17,代码来源:periodicity.py

示例2: adapter_enforce_gmt

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
def adapter_enforce_gmt(dt=None):
    if dt != None:
        dt = DateTime(dt)
        t = dt.timeTime()
        gmt_date = DateTime(t,gmt_offset(dt))
        return gmt_date
    return DateTime()
开发者ID:uwosh,项目名称:uwosh.library.ws,代码行数:9,代码来源:timeutil.py

示例3: _FSCacheHeaders

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
def _FSCacheHeaders(obj):

    REQUEST = getattr(obj, 'REQUEST', None)
    if REQUEST is None:
        return False

    RESPONSE = REQUEST.RESPONSE
    header = REQUEST.get_header('If-Modified-Since', None)
    last_mod = obj._file_mod_time

    if header is not None:
        header = header.split(';')[0]
        # Some proxies seem to send invalid date strings for this
        # header. If the date string is not valid, we ignore it
        # rather than raise an error to be generally consistent
        # with common servers such as Apache (which can usually
        # understand the screwy date string as a lucky side effect
        # of the way they parse it).
        try:
            mod_since=DateTime(header)
            mod_since=long(mod_since.timeTime())
        except TypeError:
            mod_since=None
               
        if mod_since is not None:
            if last_mod > 0 and last_mod <= mod_since:
                RESPONSE.setStatus(304)
                return True

    #Last-Modified will get stomped on by a cache policy if there is
    #one set....
    RESPONSE.setHeader('Last-Modified', rfc1123_date(last_mod))
开发者ID:goschtl,项目名称:zope,代码行数:34,代码来源:utils.py

示例4: _zope_datetime

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
 def _zope_datetime(self, field, zone=None):
     dt = self.doc.get(field)
     if dt is None:
         return None
     dt = DateTime(dt)
     if zone is None:
         zone = DateTime().localZone(localtime(dt.timeTime()))
     return dt.toZone(zone)
开发者ID:4teamwork,项目名称:ftw.solr,代码行数:10,代码来源:contentlisting.py

示例5: testDebugModeSplitting2

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
 def testDebugModeSplitting2(self):
     self.tool.registerKineticStylesheet("ham")
     now = DateTime()
     days = 7
     soon = now + days
     self.tool.setDebugMode(True)
     # Publish in debug mode
     response = self.publish(self.toolpath + "/ham")
     self.failIfEqual(response.getHeader("Expires"), rfc1123_date(soon.timeTime()))
     self.assertEqual(response.getHeader("Expires"), rfc1123_date(now.timeTime()))
     self.assertEqual(response.getHeader("Cache-Control"), "max-age=0")
开发者ID:nacho22martin,项目名称:tesis,代码行数:13,代码来源:testKSSRegistry.py

示例6: convert_bind_param

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
    def convert_bind_param( self, value, engine ):
        if value is None:
            return None
        if isinstance( value, DateTime ):
            value = DateFromTicks( DateTime.timeTime() )

        # psycopg1 specific hack
        if hasattr( engine, 'version') and engine.version == 1:
            return engine.module.TimestampFromMx( value )

        return value
开发者ID:collective,项目名称:Products.CMFDeployment,代码行数:13,代码来源:archetypes.py

示例7: lastDate

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
 def lastDate(self, *dates):
     if len(dates) == 0:
         return self.portal_cache_settings.getChangeDate()
     dates = list(dates)
     timeout = self.getEtagTimeout()
     if timeout:
         time = DateTime()
         time = timeout * (int(time.timeTime()/timeout) - 1)
         time = DateTime(time)
         dates.append(time)
     dates.sort()
     return dates[-1]
开发者ID:kroman0,项目名称:products,代码行数:14,代码来源:base_cache_rule.py

示例8: testDebugModeSplitting2

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
 def testDebugModeSplitting2(self):
     self.tool.registerKineticStylesheet('ham')
     now = DateTime()
     days = 7
     soon = now + days
     self.tool.setDebugMode(True)
     # Publish in debug mode
     response = self.publish(self.toolpath+'/ham')
     self.tool.setDebugMode(False)
     self.failIfEqual(response.getHeader('Expires'), rfc1123_date(soon.timeTime()))
     self.assertEqual(response.getHeader('Expires'), rfc1123_date(now.timeTime()))
     self.assertEqual(response.getHeader('Cache-Control'), 'max-age=0')
开发者ID:RedTurtle,项目名称:Products.ResourceRegistries,代码行数:14,代码来源:testKSSRegistry.py

示例9: testDebugModeSplitting2

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
 def testDebugModeSplitting2(self):
     self.tool.registerScript('ham')
     # Publish in normal mode
     response = self.publish(self.toolpath+'/ham')
     now = DateTime()
     days = 7
     soon = now + days
     self.tool.setDebugMode(True)
     # Publish in debug mode
     response = self.publish(self.toolpath+'/ham')
     self.assertExpiresNotEqual(response.getHeader('Expires'), soon.timeTime())
     self.assertExpiresEqual(response.getHeader('Expires'), now.timeTime())
     self.assertEqual(response.getHeader('Cache-Control'), 'max-age=0')
开发者ID:urska19,项目名称:Plone-test,代码行数:15,代码来源:testJSRegistry.py

示例10: set

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
 def set(self, instance, value, **kwargs):
     if not value:
         value = None
     elif not isinstance(value, DateTime):
         try:
             value = DateTime(value)
             if value.timezoneNaive():
                 zone = value.localZone(safelocaltime(value.timeTime()))
                 parts = value.parts()[:-1] + (zone,)
                 value = DateTime(*parts)
         except DateTimeError:
             value = None
     super(XSharedBuyablePeriodDateTimeField, self).set(
         instance, value, **kwargs)
开发者ID:,项目名称:,代码行数:16,代码来源:

示例11: getInactivitat

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
    def getInactivitat(self):
        """
            Returns the days from the last login.
        """
        days = -1
        if self.properties.hasProperty('last_login') == 1 :
            isodate = self.properties.last_login
            dt = DateTime(isodate)
            last_access = dt.timeTime()
            # Restem la diferecia de les dates en segons i obtenim els minuts /60
            minutes = int((DateTime().timeTime() - last_access)/60.0)
            # Els dies son els minuts per hora i les hores per dia
            days = int(minutes/60/24)

        return  days
开发者ID:UPCnet,项目名称:upcnet.stats,代码行数:17,代码来源:stats.py

示例12: testDebugModeSplitting2

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
    def testDebugModeSplitting2(self):
        self.tool.registerScript('ham')
        # Publish in normal mode
        response = self.publish(self.toolpath+'/ham')
        now = DateTime()
        days = 7
        soon = now + days
        self.assertEqual(response.getStatus(), 200)
        self.assertEqual(response.getHeader('Expires'), rfc1123_date(soon.timeTime()))
        self.assertEqual(response.getHeader('Cache-Control'), 'max-age=%d' % int(days*24*3600))

        # Set debug mode
        self.tool.setDebugMode(True)
        self.tool.cookResources()
        # Publish in debug mode
        response = self.publish(self.toolpath+'/ham')
        self.failIfEqual(response.getHeader('Expires'), rfc1123_date(soon.timeTime()))
        self.assertEqual(response.getHeader('Expires'), rfc1123_date(now.timeTime()))
        self.assertEqual(response.getHeader('Cache-Control'), 'max-age=0')
开发者ID:dtgit,项目名称:dtedu,代码行数:21,代码来源:testJSRegistry.py

示例13: _massageValue

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
    def _massageValue(self, value, field):
        """ Do some extra massaging for the case of:
        - list types (store as delimited text)
        """
        if field.meta_type == 'FormDateField':
            # Use Zope's easy DateTime conversion
            zope_dt = ZopeDateTime(value)
            value = datetime.fromtimestamp(zope_dt.timeTime())
        elif field.meta_type == 'FormLikertField':
            # converts the likert dict to a comma-separated string of
            # question: answer
            items = []
            for i in range(len(value)):
                label = field.fgField.questionSet[i]
                items.append('%s: %s' % (label, value.get(str(i + 1), '')))
            value = items

        # Convert list values
        if isinstance(value, list):
            # Store lines newline-separated?
            value = DELIMITER.join(value)
        return value
开发者ID:netsight,项目名称:Products.sqlpfgadapter,代码行数:24,代码来源:sqlAdapter.py

示例14: gcommons_userfriendly_date

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
def gcommons_userfriendly_date(a_datetime):
    """
    a_datetime can be a string or DateTime object
    
    returns a string
    """
    now = datetime.now()
    if type(a_datetime) is str:
        a_datetime = DateTime(a_datetime)

    diff = now - datetime.fromtimestamp(a_datetime.timeTime())
    second_diff = diff.seconds
    day_diff = diff.days

    if day_diff < 0:
        return ''

    if day_diff == 0:
        if second_diff < 10:
            return "just now"
        if second_diff < 60:
            return str(second_diff) + " seconds ago"
        if second_diff < 120:
            return  "a minute ago"
        if second_diff < 3600:
            return str( second_diff / 60 ) + " minutes ago"
        if second_diff < 7200:
            return "an hour ago"
        if second_diff < 86400:
            return str( second_diff / 3600 ) + " hours ago"
    if day_diff == 1:
        return "Yesterday"
    if day_diff < 7:
        return str(day_diff) + " days ago"
    if day_diff < 31:
        return str(day_diff/7) + " weeks ago"
    if day_diff < 365:
        return str(day_diff/30) + " months ago"
    return str(day_diff/365) + " years ago"
开发者ID:jgrigera,项目名称:Journal-Commons,代码行数:41,代码来源:gctime.py

示例15: wrapperSupportModifiedSince

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import timeTime [as 别名]
    def wrapperSupportModifiedSince(self, *args, **kwargs):
      modified_since = self.REQUEST.getHeader('If-Modified-Since')
      if modified_since is not None:
        # RFC 2616 If-Modified-Since support
        try:
          modified_since = DateTime(self.REQUEST.getHeader('If-Modified-Since'))
        except Exception:
          # client sent wrong header, shall be ignored
          pass
        else:
          if modified_since <= DateTime():
            # client send date before current time, shall continue and
            # compare with second precision, as client by default shall set
            # If-Modified-Since to last known Last-Modified value
            document = self.restrictedTraverse(getattr(self, document_url_id))
            document_date = document.getModificationDate() or \
              document.bobobase_modification_time()
            if int(document_date.timeTime()) <= int(modified_since.timeTime()):
              # document was not modified since
              self.REQUEST.response.setStatus(304)
              return self.REQUEST.response

      return fn(self, *args, **kwargs)
开发者ID:pombredanne,项目名称:slapos.core,代码行数:25,代码来源:SlapOSRestAPIV1.py


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