2021-12-31 19:16:12 +01:00
|
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
# Copyright (C) 2022 Francesco Gazzetta
|
|
|
|
|
|
|
|
"""Digital clock with weekday
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Shows a time (as HH:MM) together with a battery meter, the date, and the weekday.
|
|
|
|
|
2023-03-07 02:02:07 +01:00
|
|
|
.. figure:: res/screenshots/WeekClockApp.png
|
2021-12-31 19:16:12 +01:00
|
|
|
:width: 179
|
|
|
|
"""
|
|
|
|
|
2023-03-07 02:02:07 +01:00
|
|
|
from apps.user.clock import ClockApp, MONTH
|
2021-12-31 19:16:12 +01:00
|
|
|
|
|
|
|
WDAY = 'MonTueWedThuFriSatSun'
|
|
|
|
|
|
|
|
class WeekClockApp(ClockApp):
|
|
|
|
NAME = 'WeekClk'
|
|
|
|
|
|
|
|
def _day_string(self, now):
|
|
|
|
"""Produce a string representing the current day"""
|
|
|
|
# Format the month as text
|
|
|
|
month = now[1] - 1
|
|
|
|
month = MONTH[month*3:(month+1)*3]
|
|
|
|
|
|
|
|
# Format the weekday as text
|
|
|
|
wday = now[6]
|
|
|
|
wday = WDAY[wday*3:(wday+1)*3]
|
|
|
|
|
|
|
|
return '{} {} {} {}'.format(wday, now[2], month, now[0])
|