Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@
// This is done to show the time in server's timezone
// because RadiusAccounting admin also shows the time in server's timezone.
let strippedDateTime = new Date(dateTimeString.replace(/[-+]\d{2}:\d{2}$/, ""));
return strippedDateTime.toLocaleString();
const locale = djangoLocale.replace("_", "-");
const options = {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
};
Comment on lines +23 to +31
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Find the file mentioned in the review
find . -name "device-change.js" -type f

Repository: openwisp/openwisp-radius

Length of output: 154


🏁 Script executed:

#!/bin/bash

# Let's also check the structure of the monitoring module
find . -path "*monitoring/static/radius-monitoring*" -type f | head -20

Repository: openwisp/openwisp-radius

Length of output: 243


🏁 Script executed:

cat -n ./openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.js

Repository: openwisp/openwisp-radius

Length of output: 5156


🏁 Script executed:

#!/bin/bash

# Search for djangoLocale definition/usage
rg "djangoLocale" --type js

# Search for where this JS file is included/rendered
rg "device-change.js" 

# Look for locale configuration in Django templates
fd -e "html" -e "py" | xargs rg -l "djangoLocale" 2>/dev/null | head -10

Repository: openwisp/openwisp-radius

Length of output: 412


🏁 Script executed:

cat -n ./openwisp_radius/integrations/monitoring/templates/admin/config/radius-monitoring/device/change_form.html

Repository: openwisp/openwisp-radius

Length of output: 2286


🏁 Script executed:

#!/bin/bash

# Search for other toLocaleString usages
rg "toLocaleString" 

# Search for hour12 settings in the codebase
rg "hour12"

# Check the admin.py for any additional context
head -50 ./openwisp_radius/integrations/monitoring/admin.py

Repository: openwisp/openwisp-radius

Length of output: 1543


Remove hour12: false to respect locale preferences.

hour12: false forces 24-hour format regardless of locale, preventing Django's locale setting from taking full effect. Different locales have different time conventions (e.g., en-US prefers 12-hour, en-GB prefers 24-hour). Removing this option allows toLocaleString() to use the locale's natural preference.

🔧 Proposed fix
       const options = {
         year: "numeric",
         month: "short",
         day: "numeric",
         hour: "2-digit",
         minute: "2-digit",
         second: "2-digit",
-        hour12: false,
       };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const options = {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
};
const options = {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
};
🤖 Prompt for AI Agents
In
`@openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.js`
around lines 23 - 31, The options object in device-change.js contains hour12:
false which forces 24-hour time; remove the hour12 property from the options
constant so toLocaleString() can honor the user's locale preferences (locate and
edit the options declaration in device-change.js where the options object with
year/month/day/hour/minute/second is defined and delete the hour12: false
entry).

return strippedDateTime.toLocaleString(locale, options);
}

function fetchRadiusSessions() {
Expand Down
Loading