Formats the given date as a day of week. Example: "Monday, January 22". You can remove the day of week with ``dow=False``.
(
self, date: datetime.datetime, gmt_offset: int = 0, dow: bool = True
)
| 426 | } |
| 427 | |
| 428 | def format_day( |
| 429 | self, date: datetime.datetime, gmt_offset: int = 0, dow: bool = True |
| 430 | ) -> bool: |
| 431 | """Formats the given date as a day of week. |
| 432 | |
| 433 | Example: "Monday, January 22". You can remove the day of week with |
| 434 | ``dow=False``. |
| 435 | """ |
| 436 | local_date = date - datetime.timedelta(minutes=gmt_offset) |
| 437 | _ = self.translate |
| 438 | if dow: |
| 439 | return _("%(weekday)s, %(month_name)s %(day)s") % { |
| 440 | "month_name": self._months[local_date.month - 1], |
| 441 | "weekday": self._weekdays[local_date.weekday()], |
| 442 | "day": str(local_date.day), |
| 443 | } |
| 444 | else: |
| 445 | return _("%(month_name)s %(day)s") % { |
| 446 | "month_name": self._months[local_date.month - 1], |
| 447 | "day": str(local_date.day), |
| 448 | } |
| 449 | |
| 450 | def list(self, parts: Any) -> str: |
| 451 | """Returns a comma-separated list for the given list of parts. |