Skip to content

Commit e63943a

Browse files
committed
Ensure scheduler.py also uses Singapore Time by default
1 parent 24f98d4 commit e63943a

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

scheduler.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
from pathlib import Path
1818

1919
try:
20-
import pytz
21-
HAS_PYTZ = True
20+
from src.config import SGT
2221
except ImportError:
23-
HAS_PYTZ = False
24-
print("Warning: pytz not installed. Using local timezone.")
25-
print("Install with: pip install pytz")
22+
import pytz
23+
SGT = pytz.timezone('Asia/Singapore')
24+
25+
import pytz
26+
HAS_PYTZ = True
2627

2728

2829
def parse_args():
@@ -61,8 +62,7 @@ def get_next_run_time(target_time_str, timezone_str):
6162
hour, minute = map(int, target_time_str.split(':'))
6263

6364
if HAS_PYTZ:
64-
tz = pytz.timezone(timezone_str)
65-
now = datetime.now(tz)
65+
now = datetime.now(SGT)
6666
else:
6767
now = datetime.now()
6868

@@ -91,7 +91,7 @@ def run_bot(dry_run=False, verify=False):
9191
cmd.append('--verify')
9292

9393
print(f"\n{'='*60}")
94-
print(f"Starting bot at {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
94+
print(f"Starting bot at {datetime.now(SGT).strftime('%Y-%m-%d %H:%M:%S')}")
9595
print(f"{'='*60}\n")
9696

9797
result = subprocess.run(cmd, cwd=script_dir)
@@ -112,8 +112,7 @@ def main():
112112
next_run = get_next_run_time(args.time, args.timezone)
113113

114114
if HAS_PYTZ:
115-
tz = pytz.timezone(args.timezone)
116-
now = datetime.now(tz)
115+
now = datetime.now(SGT)
117116
else:
118117
now = datetime.now()
119118

@@ -128,7 +127,7 @@ def main():
128127
time.sleep(sleep_time)
129128

130129
if HAS_PYTZ:
131-
now = datetime.now(tz)
130+
now = datetime.now(SGT)
132131
else:
133132
now = datetime.now()
134133
wait_seconds = (next_run - now).total_seconds()

0 commit comments

Comments
 (0)