summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5e3104b)
raw | patch | inline | side by side (parent: 5e3104b)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sat, 12 Oct 2002 23:10:36 +0000 (23:10 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sat, 12 Oct 2002 23:10:36 +0000 (23:10 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1345 57a73879-2fb5-44c3-a270-3262357dd7e2
CHANGES.txt | patch | blob | history | |
roundup/cgi/templating.py | patch | blob | history | |
roundup/date.py | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index 5bbc01a32f98b19f997e605acdb49b3c61c38de1..f4a3df83e777c4e261e10d9d1847f03f8c69531c 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
- issues in 'done-cbb' are now also moved to 'chatting' on new messages
- implemented the missing Interval.__add__
- added ability to implement new templating utility methods
+- expose the Date.pretty method to templating
2002-10-02 0.5.0
index 0a82a17f6647b3e2fdebe9dca602fc4ff8571ded..e7802dc78d496580d04df746444e3157164c6b0a 100644 (file)
return interval.pretty()
return str(interval)
+ def pretty(self, format='%d %B %Y'):
+ ''' Render the date in a pretty format (eg. month names, spaces).
+
+ The format string is a standard python strftime format string.
+ Note that if the day is zero, and appears at the start of the
+ string, then it'll be stripped from the output. This is handy
+ for the situatin when a date only specifies a month and a year.
+ '''
+ return self._value.pretty()
+
class IntervalHTMLProperty(HTMLProperty):
def plain(self):
''' Render a "plain" representation of the property
diff --git a/roundup/date.py b/roundup/date.py
index 6299318d0cbbb65a299f61d465e68e01cb885ba6..54265d170431c02edbb610749a3487a55f3e6515 100644 (file)
--- a/roundup/date.py
+++ b/roundup/date.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: date.py,v 1.35 2002-10-11 01:25:40 richard Exp $
+# $Id: date.py,v 1.36 2002-10-12 23:10:36 richard Exp $
__doc__ = """
Date, time and time interval handling.
return '%4d-%02d-%02d.%02d:%02d:%02d'%(self.year, self.month, self.day,
self.hour, self.minute, self.second)
- def pretty(self):
+ def pretty(self, format='%d %B %Y'):
''' print up the date date using a pretty format...
+
+ Note that if the day is zero, and the day appears first in the
+ format, then the day number will be removed from output.
'''
- str = time.strftime('%d %B %Y', (self.year, self.month,
- self.day, self.hour, self.minute, self.second, 0, 0, 0))
- if str[0] == '0': return ' ' + str[1:]
+ str = time.strftime(format, (self.year, self.month, self.day,
+ self.hour, self.minute, self.second, 0, 0, 0))
+ # handle zero day by removing it
+ if format.startswith('%d') and str[0] == '0':
+ return ' ' + str[1:]
return str
def set(self, spec, offset=0, date_re=re.compile(r'''