Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid time value #2

Closed
malago86 opened this issue Jul 31, 2021 · 1 comment
Closed

Invalid time value #2

malago86 opened this issue Jul 31, 2021 · 1 comment

Comments

@malago86
Copy link

malago86 commented Jul 31, 2021

I think I put a date that was invalid for some validator.

Initially it accepted the date (in 2050 because there is no permanent ban) but when I try to edit the shadow ban it shows me this error:

mount-redraw.js:15 RangeError: Invalid time value
    at Date.toISOString (<anonymous>)
    at p.h.toISOString (dayjs.min.js:1)
    at a.e.oninit (BanUserModal.ts:30)
    at Function.a (render.js:30)
    at M (render.js:917)
    at render.js:153
    at render.js:160
    at l (render.js:66)
    at f (render.js:423)
    at h (render.js:302)

On this line of code:

if (until) {
            // @ts-ignore dayjs type-hints not available
            **this.until = dayjs(until).toISOString().substring(0, 16); // Remove timezone and seconds for compatibility with datetime-local**
        }

The database shows the banned until as 0000-00-00 00:00:00 so I guess it did not save correctly! Database won't accept 2050 as a date, I think that's the issue, any idea why?

@clarkwinkelmann
Copy link
Owner

Thanks for the report!

For now I have just added a validation error message if the date is after 2038-01-19 03:14:07, which is the maximum value for the TIMESTAMP MySQL column used in the database.

I have also fixed the frontend so the interface doesn't break if an invalid value is already in the database.

I'm not actually sure what to do with the column type yet. I see Flarum Suspend uses a DATETIME which can be bigger than 2038, but there's plenty more columns that still use TIMESTAMP in Flarum and will need to be updated in the future.

I'll probably switch all the date columns of all my extensions to DATETIME in one go at some point in the future.

I think using 2038 dates should work as a good enough workaround for now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants