diff --git a/src/wuttjamaican/app.py b/src/wuttjamaican/app.py index a623af8..d8483b4 100644 --- a/src/wuttjamaican/app.py +++ b/src/wuttjamaican/app.py @@ -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): """ diff --git a/tests/test_app.py b/tests/test_app.py index 3693b2d..1070e28 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -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)