bito-code-review[bot] commented on PR #43839:
URL: https://github.com/apache/superset/pull/43839#issuecomment-5534587878
<!-- Bito Reply -->
The issue is correct. The current implementation uses a regex `/^-?\d+$/` to
identify integer strings and treats them as millisecond timestamps. This causes
short numeric strings like "2017" to be interpreted as the year 1970
(specifically, 2 seconds after the Unix epoch) rather than the year 2017.
To resolve this, you should add a check to ensure the numeric string
represents a reasonable timestamp range (e.g., by checking its length or value)
before treating it as a millisecond timestamp. Alternatively, you could require
a minimum length for integer strings to be treated as timestamps.
Would you like me to implement a fix for this issue? If you agree, I can
also check the other comments on this PR and help you resolve them as well.
**superset-frontend/packages/superset-ui-core/src/time-format/utils/stringifyTimeInput.ts**
```
const trimmed = value.trim();
const isIntegerString = /^-?\d+$/.test(trimmed);
// Consider adding a length check here, e.g., trimmed.length > 4
time = new Date(isIntegerString ? Number(trimmed) : value);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]