2 Mixins for methods used by several model classes.
4 from calendar import timegm
5 from xonstat.util import pretty_date, html_colors
8 class FuzzyDateMixin(object):
9 """Provides a class with a "create_dt" attribute the ability to return a fuzzy date."""
12 return pretty_date(self.create_dt)
15 class EpochMixin(object):
16 """Provides a class with a "create_dt" attribute the ability to return the epoch time."""
19 return timegm(self.create_dt.timetuple())
22 class NickColorsMixin(object):
23 """Provides a class with a "nick" attribute the ability to return the nick's HTML colors."""
25 def nick_html_colors(self, limit=None):
27 return "Anonymous Player"
29 return html_colors(self.nick, limit)