Coverage for health / utils / time_utils.py: 0%

8 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-02 17:44 +0800

1from datetime import datetime, timedelta, timezone, date 

2 

3 

4def get_cst_now() -> datetime: 

5 """Returns the current datetime in UTC+8 (China Standard Time).""" 

6 tz = timezone(timedelta(hours=8)) 

7 return datetime.now(tz) 

8 

9 

10def get_cst_today() -> date: 

11 """Returns today's date in UTC+8 (China Standard Time).""" 

12 return get_cst_now().date() 

13 

14 

15def get_current_time_str() -> str: 

16 """ 

17 Returns the current time in UTC+8 (China Standard Time). 

18 Format: YYYY-MM-DD HH:MM:SS (CST) 

19 """ 

20 return get_cst_now().strftime("%Y-%m-%d %H:%M:%S (CST)") 

21