1
1
mirror of https://github.com/OpenVoiceOS/OpenVoiceOS synced 2025-06-05 22:19:21 +02:00

[WIP] Pushed for backup.

... Do not build this as of yet ...
This commit is contained in:
j1nx
2023-06-01 15:16:04 +02:00
parent 5c7af8b058
commit c6460b9307
417 changed files with 43487 additions and 76 deletions

View File

@ -0,0 +1,43 @@
from ..formatting import Formatter
_formatter = Formatter()
class FormattableMixin(object):
_formatter = _formatter
def format(self, fmt, locale=None):
"""
Formats the instance using the given format.
:param fmt: The format to use
:type fmt: str
:param locale: The locale to use
:type locale: str or None
:rtype: str
"""
return self._formatter.format(self, fmt, locale)
def for_json(self):
"""
Methods for automatic json serialization by simplejson
:rtype: str
"""
return str(self)
def __format__(self, format_spec):
if len(format_spec) > 0:
if "%" in format_spec:
return self.strftime(format_spec)
return self.format(format_spec)
return str(self)
def __str__(self):
return self.isoformat()