discordia plug in

Lee Joramo <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <[email protected]>
Okay, I got my "Hello World" plug in working. In playing with this, I 
found that the plug ins can be far simpler than I originally thought.

So from there I have created a plugin to provide the Discordia date. 
Pretty useless, but that  is the point.

Lee Joramo


---discordia.py--START---
def getDiscordia():
    import time
    zeit = time.localtime(time.time())
    daynum = zeit[-2] #Day of year
    year = zeit[0] #for St. Tibb's Day logic
    dyear = year + 1166
    #Gregorian Calendar rules for leap year
    if year % 400 == 0:
       tibs = 1
    elif not (year % 100 == 0) and (year % 4 == 0):
       tibs = 1
    else:
       tibs = 0
    if tibs and daynum == 60:
       day = "St. Tib's Day, 59 1/2 of Chaos, %s" % dyear
       return day
    if tibs and daynum > 60:
       daynum -= 1
       # St. Tib's Day exists seperate from the rest of the calendar
       # ---  Apparently, it's in somebody's freezer or something.
    #daynum%5 == 0 means that it's the fifth day; no day zero.
    dayname = (
        'Setting Orange','Sweetmorn', 'Boomtime',
        'Pungenday', 'Prickle-Prickle')[(daynum) % 5]
    daynumber = ((daynum - 1) % 73) + 1
    season = (
        'Chaos', 'Discord', 'Confusion',
        'Bureaucracy', 'The Aftermath')[(daynum-1) / 73]
    return  "%s, %d of %s, %s" % (dayname, daynumber, season, dyear)

def load(py, entryList):
     py["discordia"] = getDiscordia()
---discordia.py--END---



-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.