Skip to content

Instantly share code, notes, and snippets.

@horiajurcut
Last active January 1, 2016 07:59
Show Gist options
  • Save horiajurcut/8115524 to your computer and use it in GitHub Desktop.
Save horiajurcut/8115524 to your computer and use it in GitHub Desktop.
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()
@mebusila
Copy link

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

@horiajurcut
Copy link
Author

This escalated quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment