MetiMiester commited on
Commit
57ae0a7
·
verified ·
1 Parent(s): a0b55cd

Update src/utils/time_utils.py

Browse files
Files changed (1) hide show
  1. src/utils/time_utils.py +37 -15
src/utils/time_utils.py CHANGED
@@ -1,19 +1,41 @@
1
- TZ_NAME = "Asia/Muscat"
 
2
 
3
- ROOM_STATUS = ["free", "occupied", "need_cleaning", "out_of_service"]
 
4
 
5
- STATUS_COLORS = {
6
- "free": "#ffffff",
7
- "occupied": "#8e44ad",
8
- "need_cleaning": "#e74c3c",
9
- "out_of_service": "#95a5a6",
10
- }
11
 
12
- STATUS_TEXT_COLORS = {
13
- "free": "#000000", # REQUIRED: black on white tiles
14
- "occupied": "#ffffff",
15
- "need_cleaning": "#ffffff",
16
- "out_of_service": "#000000",
17
- }
18
 
19
- PAYMENT_METHODS = ["cash", "card", "bank", "other"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime, timedelta
2
+ import pytz
3
 
4
+ # Hotel timezone
5
+ OMAN_TZ = pytz.timezone("Asia/Muscat")
6
 
 
 
 
 
 
 
7
 
8
+ def utc_now_iso() -> str:
9
+ """
10
+ Returns current UTC time in ISO-8601 format.
11
+ Used for all audit-safe timestamps.
12
+ """
13
+ return datetime.utcnow().replace(microsecond=0).isoformat() + "Z"
14
 
15
+
16
+ def local_now() -> datetime:
17
+ """
18
+ Returns current local time in Asia/Muscat timezone.
19
+ """
20
+ return datetime.now(OMAN_TZ)
21
+
22
+
23
+ def local_date_str() -> str:
24
+ """
25
+ Returns local date (Asia/Muscat) as YYYY-MM-DD.
26
+ """
27
+ return local_now().strftime("%Y-%m-%d")
28
+
29
+
30
+ def business_date_for_closing(now: datetime | None = None) -> str:
31
+ """
32
+ Business day closes at 06:00 Asia/Muscat.
33
+ - Before 06:00 → business day = yesterday
34
+ - After 06:00 → business day = today
35
+ """
36
+ if now is None:
37
+ now = local_now()
38
+
39
+ if now.hour < 6:
40
+ return (now.date() - timedelta(days=1)).isoformat()
41
+ return now.date().isoformat()