Welcome to the CHICKEN Scheme pasting service

no title added by anonymous on Tue Jul 3 14:28:45 2012

#!/usr/local/bin/python

import time
import sys
import os
import getopt

def number_to_lojban(number):
    number_str = "%d" % number
    result = ""
    for char in number_str:
        if char == "0":
            result += "no"
        elif char == "1":
            result += "pa"
        elif char == "2":
            result += "re"
        elif char == "3":
            result += "ci"
        elif char == "4":
            result += "vo"
        elif char == "5":
            result += "mu"
        elif char == "6":
            result += "xa"
        elif char == "7":
            result += "ze"
        elif char == "8":
            result += "bi"
        elif char == "9":
            result += "so"
    return result

def usage():
    print "jbotime [-d|--date] [-t|--time]"
    print "Print the date, time, or both in Lojban."
    print "Defaults to just the time if nothing is specified."

now = time.localtime()

try:
    opts, args = getopt.getopt(sys.argv[1:], "hdt", ["help", "date", "time"])
except getopt.GetoptError, err:
    # print help information and exit:
    print str(err) # will print something like "option -a not recognized"
    usage()
    sys.exit(2)
date = False
time = False
for o, a in opts:
    if o in ("-d", "--date"):
        date = True
    elif o in ("-t", "--time"):
        time = True
    elif o in ("-h", "--help"):
        usage()
        sys.exit()
    else:
        assert False, "unhandled option %s" % o

if not date and not time:
    time = True

output = ""

if date:
    output += ".i li %s pi'e %s pi'e %s detri" % (number_to_lojban(now.tm_year), number_to_lojban(now.tm_mon), number_to_lojban(now.tm_mday))

if date and time:
    output += " "

if time:
    if now.tm_min == 0:
        output += ".i li %s tcika" % number_to_lojban(now.tm_hour)
    else:
        output += ".i li %s pi'e %s tcika" % (number_to_lojban(now.tm_hour),number_to_lojban(now.tm_min))

print output

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which operator can be represented by an apostrophe?
Visually impaired? Let me spell it for you (wav file) download WAV