Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/pendulum/mixins/default.py : 50%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from ..formatting import Formatter
4_formatter = Formatter()
7class FormattableMixin(object):
9 _formatter = _formatter
11 def format(self, fmt, locale=None):
12 """
13 Formats the instance using the given format.
15 :param fmt: The format to use
16 :type fmt: str
18 :param locale: The locale to use
19 :type locale: str or None
21 :rtype: str
22 """
23 return self._formatter.format(self, fmt, locale)
25 def for_json(self):
26 """
27 Methods for automatic json serialization by simplejson
29 :rtype: str
30 """
31 return str(self)
33 def __format__(self, format_spec):
34 if len(format_spec) > 0:
35 if "%" in format_spec:
36 return self.strftime(format_spec)
38 return self.format(format_spec)
40 return str(self)
42 def __str__(self):
43 return self.isoformat()