rusackas commented on code in PR #43909:
URL: https://github.com/apache/superset/pull/43909#discussion_r3939705683
##########
superset-frontend/packages/superset-ui-core/src/time-format/utils/stringifyTimeInput.ts:
##########
@@ -28,16 +28,27 @@ export default function stringifyTimeInput(
let time: Date;
if (typeof value === 'string') {
const trimmed = value.trim();
+ // A bare four-digit string is the ISO 8601 year-only form ("2017"), which
+ // every engine parses as January 1st of that year. Any other integer
+ // string is an epoch timestamp in milliseconds that was stringified on
+ // its way here, e.g. by the pivot table, and is not a valid Date input.
+ const isYear = /^\d{4}$/.test(trimmed);
const isIntegerString = /^-?\d+$/.test(trimmed);
- time = new Date(isIntegerString ? Number(trimmed) : value);
+ if (isYear) {
+ time = new Date(trimmed);
+ } else {
+ time = new Date(isIntegerString ? Number(trimmed) : value);
+ }
Review Comment:
That's the tradeoff I called out in the description. A bare 4-digit epoch-ms
value means under 10 seconds past 1970, nobody's actually displaying that,
while 4-digit years are exactly what #38949 broke. Keeping the carve-out narrow
on purpose.
--
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]