Compare commits
2 Commits
9cbc90cc37
...
26554c7f29
| Author | SHA1 | Date | |
|---|---|---|---|
| 26554c7f29 | |||
| 51286ae181 |
Binary file not shown.
Binary file not shown.
@@ -13,9 +13,9 @@
|
||||
|
||||
<!-- 顶部标题 -->
|
||||
<header class="bg-gray-50 dark:bg-gray-800 dark:border-gray-700 p-4 text-center text-xl font-bold">
|
||||
分支机构活动管理
|
||||
分支机构活动管理 {{ ''|get_current_year }}年
|
||||
<br>
|
||||
2025年
|
||||
<small>统计周期:{{ ''|get_statistic_period }}</small>
|
||||
</header>
|
||||
|
||||
<!-- 主体内容:左右两侧栏布局 -->
|
||||
|
||||
Binary file not shown.
@@ -28,3 +28,47 @@ def format_chinese_full_date(value):
|
||||
weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
|
||||
weekday = weekdays[date_obj.weekday()]
|
||||
return f"{date_obj.year}年{date_obj.month}月{date_obj.day}日 {weekday}"
|
||||
|
||||
|
||||
@register.filter
|
||||
def get_current_year(value=None):
|
||||
"""
|
||||
获取当前年份
|
||||
"""
|
||||
# 只有当value是datetime对象时才使用它,否则使用当前时间
|
||||
if isinstance(value, datetime):
|
||||
now = value
|
||||
else:
|
||||
now = datetime.now()
|
||||
return now.year
|
||||
|
||||
|
||||
@register.filter
|
||||
def get_statistic_period(value=None):
|
||||
"""
|
||||
计算统计周期
|
||||
规则:
|
||||
- 在2026年1月,实际统计的是2025年11月至2026年1月
|
||||
- 在2026年2月,实际统计的是2025年12月至2026年2月
|
||||
- 以此类推
|
||||
"""
|
||||
# 只有当value是datetime对象时才使用它,否则使用当前时间
|
||||
if isinstance(value, datetime):
|
||||
now = value
|
||||
else:
|
||||
now = datetime.now()
|
||||
current_year = now.year
|
||||
current_month = now.month
|
||||
|
||||
# 计算统计周期的开始月份和年份
|
||||
if current_month <= 2:
|
||||
start_year = current_year - 1
|
||||
start_month = 11 + current_month
|
||||
else:
|
||||
start_year = current_year
|
||||
start_month = current_month - 2
|
||||
|
||||
# 构建统计周期字符串
|
||||
period = f"{start_year}年{start_month}月至{current_year}年{current_month}月"
|
||||
|
||||
return period
|
||||
|
||||
Reference in New Issue
Block a user