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


Python Common.datetimeFromTimestamp方法代码示例

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


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

示例1: __str__

# 需要导入模块: from pyndn.util.common import Common [as 别名]
# 或者: from pyndn.util.common.Common import datetimeFromTimestamp [as 别名]
    def __str__(self):
        s = "Certificate name:\n"
        s += "  "+self.getName().toUri()+"\n"
        s += "Validity:\n"

        dateFormat = "%Y%m%dT%H%M%S"
        notBeforeStr = Common.datetimeFromTimestamp(self.getNotBefore()).strftime(dateFormat)
        notAfterStr = Common.datetimeFromTimestamp(self.getNotAfter()).strftime(dateFormat)

        s += "  NotBefore: " + notBeforeStr+"\n"
        s += "  NotAfter: " + notAfterStr + "\n"
        for sd in self._subjectDescriptionList:
            s += "Subject Description:\n"
            s += "  " + str(sd.getOid()) + ": " + sd.getValue().toRawStr() + "\n"

        s += "Public key bits:\n"
        s += Common.base64Encode(self.getPublicKeyDer().toBytes(), True)

        if len(self._extensionList) > 0:
            s += "Extensions:\n"
            for ext in self._extensionList:
                s += "  OID: "+ext.getOid()+"\n"
                s += "  Is critical: " + ('Y' if ext.isCritical() else 'N') + "\n"

                s += "  Value: " + str(ext.getValue()).encode('hex') + "\n"

        return s
开发者ID:named-data,项目名称:PyNDN2,代码行数:29,代码来源:certificate.py

示例2: _hasIntervalOnDate

# 需要导入模块: from pyndn.util.common import Common [as 别名]
# 或者: from pyndn.util.common.Common import datetimeFromTimestamp [as 别名]
    def _hasIntervalOnDate(self, timePoint):
        """
        Check if the date of the time point is in any interval.

        :param float timePoint: The time point as milliseconds since Jan 1,
          1970 UTC.
        :return: True if the date of the time point is in any interval.
        :rtype: bool
        """
        timePointDateMilliseconds = RepetitiveInterval._toDateOnlyMilliseconds(timePoint)

        if (timePointDateMilliseconds < self._startDate or
            timePointDateMilliseconds > self._endDate):
            return False

        if self._repeatUnit == RepetitiveInterval.RepeatUnit.NONE:
            return True
        elif self._repeatUnit == RepetitiveInterval.RepeatUnit.DAY:
            durationDays = ((timePointDateMilliseconds - self._startDate) /
                            RepetitiveInterval.MILLISECONDS_IN_DAY)
            if durationDays % self._nRepeats == 0:
                return True
        else:
            timePointDate = Common.datetimeFromTimestamp(
              round(timePointDateMilliseconds / 1000.0) * 1000)
            startDate = Common.datetimeFromTimestamp(self._startDate)

            if (self._repeatUnit == RepetitiveInterval.RepeatUnit.MONTH and
                  timePointDate.day == startDate.day):
                yearDifference = timePointDate.year - startDate.year
                monthDifference = (12 * yearDifference +
                  timePointDate.month - startDate.month)
                if monthDifference % self._nRepeats == 0:
                  return True
            elif (self._repeatUnit == RepetitiveInterval.RepeatUnit.YEAR and
                  timePointDate.day == startDate.day and
                  timePointDate.month == startDate.month):
                difference = timePointDate.year - startDate.year
                if difference % self._nRepeats == 0:
                  return True

        return False
开发者ID:named-data,项目名称:PyNDN2,代码行数:44,代码来源:repetitive_interval.py

示例3: toDerTimeString

# 需要导入模块: from pyndn.util.common import Common [as 别名]
# 或者: from pyndn.util.common.Common import datetimeFromTimestamp [as 别名]
    def toDerTimeString(msSince1970):
        """
        Convert a UNIX timestamp to the internal string representation
        :param msSince1970: Timestamp as milliseconds since Jan 1, 1970
        :type msSince1970: float
        :return: The time string
        :rtype: str
        """
        utcTime = Common.datetimeFromTimestamp(msSince1970)

        derTime = utcTime.strftime("%Y%m%d%H%M%SZ")
        return derTime
开发者ID:named-data,项目名称:PyNDN2,代码行数:14,代码来源:der_node.py

示例4: toIsoString

# 需要导入模块: from pyndn.util.common import Common [as 别名]
# 或者: from pyndn.util.common.Common import datetimeFromTimestamp [as 别名]
    def toIsoString(msSince1970):
        """
        Convert a UNIX timestamp to ISO time representation with the "T" in the
        middle.

        :param float msSince1970: Timestamp as milliseconds since Jan 1, 1970 UTC.
        :return: The string representation.
        :rtype: str
        """
        dateFormat = "%Y%m%dT%H%M%S"
        return Common.datetimeFromTimestamp(
          round(msSince1970 / 1000.0) * 1000).strftime(dateFormat)
开发者ID:named-data,项目名称:PyNDN2,代码行数:14,代码来源:schedule.py


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