--- /usr/bin/pypanel 2005-10-21 10:32:50.000000000 -0500 +++ pypanel 2006-03-12 18:48:52.000000000 -0600 @@ -621,7 +621,13 @@ if CLOCK: clock = panel[CLOCK] - clock.name = time.strftime(CLOCK_FORMAT, time.localtime()) + if CLOCK_FUZZY is 1: + try: + clock.name = self.fuzzyTime() + except: + clock.name = time.strftime(CLOCK_FORMAT, time.localtime()) + else: + clock.name = time.strftime(CLOCK_FORMAT, time.localtime()) clock.width = ppfontsize(clock.name) + 2 space -= clock.width + P_SPACER*2 if DESKTOP: @@ -879,12 +885,57 @@ if AUTOHIDE and not self.hidden: self.toggleHidden() if CLOCK: - now = time.strftime(CLOCK_FORMAT, time.localtime()) + if CLOCK_FUZZY is 1: + try: + now = self.fuzzyTime() + except: + now = time.strftime(CLOCK_FORMAT, time.localtime()) + else: + now = time.strftime(CLOCK_FORMAT, time.localtime()) if clock.name != now: clock.name = now self.clearPanel(clock.x1+1, 0, clock.x2-(clock.x1+1), P_HEIGHT) self.drawText(clock, clock.x1+P_SPACER, 0) - + #-------------------- + def fuzzyTime(self): + #-------------------- + now = time.localtime() + h, m = now[3], now[4] + # we aren't dealing with am/pm, this is fuzzy time + if h >= 12: + h -= 12 + hours = ( + 'twelve', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', + 'eight', 'nine', 'ten', 'eleven', 'twelve' + ) + minutes = ( + "%(hour)s o'clock", 'five past %(hour)s', + 'ten past %(hour)s', 'quarter past %(hour)s', + 'twenty past %(hour)s', 'twenty five past %(hour)s', + 'half past %(hour)s', 'twenty five till %(hour)s', + 'twenty till %(hour)s', 'quarter till %(hour)s', + 'ten till %(hour)s', 'five till %(hour)s', + "%(hour)s o'clock" + ) + # dicts don't work for this because of python silliness + # (dict methods don't return items in the order they're + # entered) + lows = (0, 4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59) + highs = (3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 59) + i = int() + for x in range(0, 13): + low = lows[x] + high = highs[x] + if m >= low and m <= high: + min = minutes[i] + break + i = i + 1 + if m > 33: + hour = hours[h + 1] + else: + hour = hours[h] + return min % {'hour': hour} + #---------------------------------------------------------------------------- # Main #---------------------------------------------------------------------------- @@ -914,6 +965,8 @@ MINIMIZED_SHADOW_COLOR = "0xffffff" DESKTOP_SHADOW_COLOR = "0xffffff" CLOCK_SHADOW_COLOR = "0xffffff" +# v2.5 +CLOCK_FUZZY = 0 #------------------------- if __name__ == "__main__":