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
 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
 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
 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