agdar/RESTART_INSTRUCTIONS.md
2025-11-02 14:35:35 +03:00

2.1 KiB

How to Apply the Timezone Fix

The Issue

You tried to clock out and the time still showed UTC (13:05) instead of Riyadh time (16:05).

Why This Happens

The code changes have been made, but they won't take effect until you restart the Django server.

Steps to Apply the Fix

1. Restart the Django Development Server

Stop the current server:

  • Press Ctrl+C in the terminal where Django is running

Start it again:

cd /Users/marwanalwali/AgdarCentre
python3 manage.py runserver

2. Clear Today's Attendance Record (Optional)

If you want to test with a fresh clock-in, you can delete today's attendance record:

python3 manage.py shell

Then in the Python shell:

from django.utils import timezone
from hr.models import Attendance
from django.contrib.auth import get_user_model

User = get_user_model()

# Replace 'your_username' with your actual username
user = User.objects.get(username='your_username')
today = timezone.now().date()

# Delete today's attendance
Attendance.objects.filter(employee=user, date=today).delete()

print("Today's attendance record deleted. You can now clock in again.")
exit()

3. Test the Fix

  1. Go to the attendance kiosk page
  2. Clock in - you should see the current Riyadh time (e.g., 16:17)
  3. Clock out - you should see the current Riyadh time

What Was Fixed

File: hr/views.py

Before:

now = timezone.now().time()  # This extracted UTC time

After:

now = timezone.localtime(timezone.now()).time()  # This extracts Riyadh time

Verification

After restarting, the time displayed should match your local Riyadh time. If it's currently 16:17 in Riyadh, that's what you should see when you clock in/out.

If It Still Doesn't Work

  1. Check that the server restarted successfully (no errors in terminal)
  2. Clear your browser cache (Ctrl+Shift+R or Cmd+Shift+R)
  3. Check the server is using the correct settings file
  4. Run the timezone test script:
    python3 test_timezone.py
    

Need Help?

If the issue persists after restarting, let me know and I can help troubleshoot further.