本文整理汇总了Python中pxStats.lib.StatsDateLib.StatsDateLib.getCurrentTimeInIsoformat方法的典型用法代码示例。如果您正苦于以下问题:Python StatsDateLib.getCurrentTimeInIsoformat方法的具体用法?Python StatsDateLib.getCurrentTimeInIsoformat怎么用?Python StatsDateLib.getCurrentTimeInIsoformat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pxStats.lib.StatsDateLib.StatsDateLib
的用法示例。
在下文中一共展示了StatsDateLib.getCurrentTimeInIsoformat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTimeOfLastUpdateInLogs
# 需要导入模块: from pxStats.lib.StatsDateLib import StatsDateLib [as 别名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import getCurrentTimeInIsoformat [as 别名]
def getTimeOfLastUpdateInLogs(self):
"""
@summary : Returns the time of the last update in iso format.
@return : None if no update as found, EPCH is returned in iso format,
as to make sure an update is made since no prior updates exist.
"""
timeOfLastUpdate = StatsDateLib.getIsoTodaysMidnight( StatsDateLib.getCurrentTimeInIsoformat() )
paths = StatsPaths()
paths.setPaths()
updatesDirectory = paths.STATSTEMPAUTUPDTLOGS + self.updateType + "/"
if not os.path.isdir( updatesDirectory ):
os.makedirs(updatesDirectory)
allEntries = os.listdir(updatesDirectory)
if allEntries !=[] :
allEntries.sort()
allEntries.reverse()
timeOfLastUpdate = os.path.basename( allEntries[0] ).replace( "_"," " )
return timeOfLastUpdate
示例2: isFirstUpdateOfTheYear
# 需要导入模块: from pxStats.lib.StatsDateLib import StatsDateLib [as 别名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import getCurrentTimeInIsoformat [as 别名]
def isFirstUpdateOfTheYear( self, timeOfUpdateInIsoFormat = "" ):
"""
@summary : Returns whether or not an update executed at
timeOfUpdateInIsoFormat would be the first update
of the year.
@timeOfUpdateInIsoFormat : Time at which the update would be executed.
@return : True or False.
"""
isFirstUpdateOfTheYear = False
lastUpdateISO = self.getTimeOfLastUpdateInLogs()
if timeOfUpdateInIsoFormat == "" :
timeOfUpdateInIsoFormat = StatsDateLib.getCurrentTimeInIsoformat()
if timeOfUpdateInIsoFormat > lastUpdateISO :
yearNumberOfLastUpdate = lastUpdateISO.split("-")[0]
yearNumberOfCurrentUpdate = timeOfUpdateInIsoFormat.split("-")[0]
if yearNumberOfLastUpdate != yearNumberOfCurrentUpdate:
isFirstUpdateOfTheYear = True
return isFirstUpdateOfTheYear
示例3: isFirstUpdateOfTheWeek
# 需要导入模块: from pxStats.lib.StatsDateLib import StatsDateLib [as 别名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import getCurrentTimeInIsoformat [as 别名]
def isFirstUpdateOfTheWeek( self, timeOfUpdateInIsoFormat = "" ):
"""
@summary : Returns whether or not an update executed at
timeOfUpdateInIsoFormat would be the first update
of the week.
@timeOfUpdateInIsoFormat : Time at which the update would be executed.
@return : True or False.
"""
isFirstUpdateOfTheWeek = False
lastUpdateISO = self.getTimeOfLastUpdateInLogs()
if timeOfUpdateInIsoFormat == "" :
timeOfUpdateInIsoFormat = StatsDateLib.getCurrentTimeInIsoformat()
if timeOfUpdateInIsoFormat > lastUpdateISO :
lastUpdateDT = datetime( int( lastUpdateISO.split("-")[0]),\
int( lastUpdateISO.split("-")[1]),\
int( lastUpdateISO.split("-")[1].split(" ")[0] )\
)
currentUpdateDT = datetime( int( timeOfUpdateInIsoFormat.split("-")[0]),\
int( timeOfUpdateInIsoFormat.split("-")[1]),\
int( timeOfUpdateInIsoFormat.split("-")[1].split(" ")[0] )\
)
weekNumberOfLastUpdate = time.strftime( '%W', time.gmtime( StatsDateLib.getSecondsSinceEpoch( lastUpdateISO ) ) )
weekNumberOfCurrentUpdate = time.strftime( '%W', time.gmtime( StatsDateLib.getSecondsSinceEpoch( timeOfUpdateInIsoFormat ) ) )
timeBetweenBothDates = currentUpdateDT - lastUpdateDT
daysBetween = timeBetweenBothDates.days
if daysBetween < 7 and ( weekNumberOfLastUpdate == weekNumberOfCurrentUpdate ): #<7 days prevents same week but from different years.
isFirstUpdateOfTheWeek = False
else:
isFirstUpdateOfTheWeek = True
return isFirstUpdateOfTheWeek
示例4: getTimeSinceLastUpdate
# 需要导入模块: from pxStats.lib.StatsDateLib import StatsDateLib [as 别名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import getCurrentTimeInIsoformat [as 别名]
def getTimeSinceLastUpdate(self, currentTimeInIsoFormat = "" ):
"""
@summary : returns the number of seconds between the last update
and the currentTime
@param currentTimeInIsoFormat: Current time specified in the ISO
format
@return : the number of seconds between the last update
and the currentTime
"""
timeBetweenUpdates = 0
if currentTimeInIsoFormat == "":
currentTimeInIsoFormat = StatsDateLib.getCurrentTimeInIsoformat()
currentTimeInSSEFormat = StatsDateLib.getSecondsSinceEpoch( currentTimeInIsoFormat )
lastUpdateInSSEFormat = StatsDateLib.getSecondsSinceEpoch( self.getTimeOfLastUpdateInLogs() )
if currentTimeInSSEFormat > lastUpdateInSSEFormat :
timeBetweenUpdates = currentTimeInSSEFormat - lastUpdateInSSEFormat
return timeBetweenUpdates