Last active
January 1, 2016 07:59
-
-
Save horiajurcut/8115524 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from datetime import timedelta | |
from datetime import date | |
class Holiday(object): | |
_message = "Hello" | |
def get_start_date(self): | |
raise NotImplementedError | |
def is_now(self): | |
current_year = date.today().year | |
day = self.get_start_date().split("-") | |
return datetime(current_year, int(day[0]), int(day[1])) - datetime.now() < timedelta(hours=24) | |
def cheer(self): | |
if self.is_now(): | |
print self._message | |
else: | |
print "Have patience my young padawan" | |
class Christmas(Holiday): | |
_message = "Hello and a Merry Christmas to all!!!" | |
def get_start_date(self): | |
return "12-25" | |
class Easter(Holiday): | |
def get_start_date(self): | |
return "4-20" | |
Christmas().cheer() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment