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


Python Ephemeris.getTimezoneOffsetFromDatetime方法代码示例

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


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

示例1: formatToDateAndDetailedTimeStr

# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import getTimezoneOffsetFromDatetime [as 别名]
def formatToDateAndDetailedTimeStr(datetimeObj):
    """Returns a string representation of a datetime.datetime object.
    Normally we wouldn't need to do this, but the datetime.strftime()
    does not work on years less than 1900. 

    Arguments:
    datetimeObj - datetime.datetime object with a tzinfo defined.

    Returns:
    String holding the info about the datetime.datetime object, in 
    the datetime.strftime() format:  "%Y-%m-%d %H:%M:%S %Z%z"
    """

    # Timezone name string, extracted from datetime.tzname().
    # This accounts for the fact that datetime.tzname() can return None.
    tznameStr = datetimeObj.tzname()
    if tznameStr == None:
        tznameStr = ""

    # Return the formatted string.
    return "{:04}-{:02}-{:02} {:02}:{:02} {}{}".\
        format(datetimeObj.year,
               datetimeObj.month,
               datetimeObj.day,
               datetimeObj.hour,
               datetimeObj.minute,
               tznameStr,
               Ephemeris.getTimezoneOffsetFromDatetime(datetimeObj))
开发者ID:philsong,项目名称:pricechartingtool,代码行数:30,代码来源:createGenericEphemerisSpreadsheet.py

示例2: getTimestampInfoDataLine

# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import getTimezoneOffsetFromDatetime [as 别名]
def getTimestampInfoDataLine(dt):
    """Takes the timestamp described by the given datetime.datetime,
    and returns a str in CSV format, describing this timestamp.

    Arguments:
    
    dt - datetime.datetime object holding the timestamp of which to
         get information on.

    Returns:
    str in CSV format, holding the information regarding this timestamp.
    The data in this string is:
    
        jd,day,date,time,timezone
        
    """

    # Return value.
    rv = ""
    
    # Field: jd
    rv += "{}".format(Ephemeris.datetimeToJulianDay(dt))
    rv += ","
    
    # Timezone name string, extracted from datetime.tzname().
    # This accounts for the fact that datetime.tzname() can return None.
    datetimeObj = dt
    tznameStr = datetimeObj.tzname()
    if tznameStr == None:
        tznameStr = ""
    dayOfWeekStr = datetimeObj.ctime()[0:3]
    offsetStr = \
        Ephemeris.getTimezoneOffsetFromDatetime(datetimeObj)
    
    # Field: day
    rv += dayOfWeekStr
    rv += ","
    
    # Field: date
    rv += "{:04}-{:02}-{:02}".\
          format(datetimeObj.year,
                 datetimeObj.month,
                 datetimeObj.day)
    #rv += "{:02}/{:02}/{:04}".\
    #      format(datetimeObj.month,
    #             datetimeObj.day,
    #             datetimeObj.year)
    rv += ","
    
    # Field: time
    rv += "{:02}:{:02}:{:02}".\
          format(datetimeObj.hour,
                 datetimeObj.minute,
                 datetimeObj.second)
    rv += ","
    
    # Field: timezone.
    rv += "{}{}".format(tznameStr, offsetStr)
    rv += ","

    # Remove trailing comma.
    rv = rv[:-1]

    return rv
开发者ID:philsong,项目名称:pricechartingtool,代码行数:66,代码来源:createFullSpreadsheetForTacSystem.py


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