from ....Dependencies.Utilities.util import *

class DateTime:
    def __init__(self,dateTime):
        self._lastUpdated = dateTime


    @property
    def lastUpdated(self):
        return self._lastUpdated

    @lastUpdated.setter
    def lastUpdated(self,dateTime):
        self._lastUpdated = dateTime

    def getchangeTimeFormatByDate(self):
        changeFormat = datetime.strptime(self._lastUpdated, "%Y/%m/%d %H:%M:%S")
        changeFormat = changeFormat.strftime("%b %d %Y %H:%M")
        return changeFormat

    def getChangeTimeFormatHavingIST(self,dateTime):
        date = dateTime.replace('IST', '+0530')
        print("line 31......")
        date_obj = datetime.strptime(date, '%a %b %d %H:%M:%S %z %Y')
        print("line 33......")
        formatted_date2 = datetime.strftime(date_obj, '%b %d %Y %H:%M')
        print("line 35......")
        return formatted_date2

    def compareDateWithDays(self,dateA,dateB,days):
        date_format = "%b %d %Y %H:%M"
        dateAvalue = datetime.strptime(dateA, date_format)
        dateBvalue = datetime.strptime(dateB, date_format)
        difference = dateAvalue - dateBvalue
        if difference.days >= days:
            # my_logger.info("I am in this line 2639")
            ColorValue = "red"         
        else:
            ColorValue = "darkgreen"
        return ColorValue