/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/util.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2007-11-19 09:08:46 UTC
  • mfrom: (140.2.2 merge-robey)
  • Revision ID: launchpad@pqm.canonical.com-20071119090846-klavrflav0efak7g
[r=jamesh] merge from upstream (small stuff only, no major changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
    return year
79
79
 
80
80
 
 
81
_g_format = '%Y-%m-%d @ %H:%M'
 
82
 
 
83
def format_date(date):
 
84
    if _g_format == 'fancy':
 
85
        return fancy_format_date(date)
 
86
    return date.strftime(_g_format)
 
87
 
 
88
def fancy_format_date(date):
 
89
    delta = datetime.datetime.now() - date
 
90
    if delta.days > 300:
 
91
        return date.strftime('%d %b %Y')
 
92
    else:
 
93
        return date.strftime('%d %b %H:%M')
 
94
 
 
95
def set_date_format(format):
 
96
    global _g_format
 
97
    _g_format = format
 
98
 
 
99
 
81
100
class Container (object):
82
101
    """
83
102
    Convert a dict into an object with attributes.