3
0
Fork 0

fix: add app.today() convenience method

This commit is contained in:
Lance Edgar 2026-01-06 22:48:34 -06:00
parent be6ac16ea7
commit b09b991d15
2 changed files with 17 additions and 1 deletions

View file

@ -630,7 +630,8 @@ class AppHandler: # pylint: disable=too-many-public-methods
For usage examples see :ref:`convert-to-localtime`.
See also :meth:`make_utc()` which is sort of the inverse.
See also :meth:`make_utc()` which is sort of the inverse; and
:meth:`today()`.
"""
kw["local_zone"] = local_zone or self.get_timezone()
return localtime(dt=dt, **kw)
@ -647,6 +648,17 @@ class AppHandler: # pylint: disable=too-many-public-methods
"""
return make_utc(dt=dt, tzinfo=tzinfo)
def today(self):
"""
Convenience method to return the current date, according
to local time zone.
See also :meth:`localtime()`.
:returns: :class:`python:datetime.date` instance
"""
return self.localtime().date()
# TODO: deprecate / remove this eventually
def make_true_uuid(self):
"""

View file

@ -510,6 +510,10 @@ app_title = WuttaTest
self.assertIsInstance(dt, datetime.datetime)
self.assertIsNone(dt.tzinfo)
def test_today(self):
today = self.app.today()
self.assertIsInstance(today, datetime.date)
def test_make_str_uuid(self):
uuid = self.app.make_str_uuid()
self.assertEqual(len(uuid), 32)