juice-shop / multi-juicer

Host and manage multiple Juice Shop instances for security trainings and Capture The Flags
Apache License 2.0
268 stars 121 forks source link

Relative time on admin page is wrong #204

Open jvmdc opened 6 months ago

jvmdc commented 6 months ago

It seems the logic surrounding the relative times for the "Created" and "Last used" column is wrong. image In the screenshot above taken today (2024-03-05), notice that it says "1 month ago". Hovering the mouse over the relative time reveals that it was in fact only on 2024-02-29, i.e. less than a week ago

bkimminich commented 6 months ago

Maybe it just means "last month", which would be correct looking at the February date from March?

jvmdc commented 6 months ago

Yup, I would agree - the wording should probably say "Last month" instead then though.

I'd argue that counting days is better since "Last month" leaves me not knowing at a glance whether it was 6 days ago or 30 days ago.

jvmdc commented 6 months ago

Without having taken a deep-dive in the code, I think the issue comes from the use of "selectUnit". Notice the "Caveats" listed here: https://www.npmjs.com/package/@formatjs/intl-utils#caveats (Also notice that the package is deprecated and selectUnit has been removed from the updated package)