-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Closed
Copy link
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
NetBox version
v3.4.2
Python version
3.10
Steps to Reproduce
- Set TIME_ZONE to 'Europe/Copenhagen` in configuration.py
- Create any test script in the script folder
- Go to the script in the UI
- Look at the label for the
Schedule atfield
In this example the current local time is 14:30:10
Expected Behavior
Schedule execution of script to a set time (current time: 2023-01-04 14:30:10)
Observed Behavior
Schedule execution of script to a set time (current time: 2023-01-04 13:30:10)
>>> from django.utils import timezone
>>> timezone.now()
datetime.datetime(2023, 1, 4, 13, 36, 22, 379154, tzinfo=datetime.timezone.utc)
>>> from django.utils.timezone import localtime
>>> localtime(timezone.now())
datetime.datetime(2023, 1, 4, 14, 38, 18, 340191, tzinfo=zoneinfo.ZoneInfo(key='Europe/Copenhagen'))
netbox/netbox/extras/forms/scripts.py
Lines 36 to 38 in 92ec06c
| # Annotate the current system time for reference | |
| now = timezone.now().strftime('%Y-%m-%d %H:%M:%S') | |
| self.fields['_schedule_at'].help_text += f' (current time: <strong>{now}</strong>)' |
netbox/netbox/extras/forms/reports.py
Lines 37 to 39 in 92ec06c
| # Annotate the current system time for reference | |
| now = timezone.now().strftime('%Y-%m-%d %H:%M:%S') | |
| self.fields['schedule_at'].help_text += f' (current time: <strong>{now}</strong>)' |
The above snippets should probably be replaced with the localtime way of getting the current time. @jeremystretch you added this, any issues with my proposed fix?
I validated the the script is scheduled at the correct set timezone and not the displayed "current time".
Metadata
Metadata
Assignees
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application