codeant-ai-for-open-source[bot] commented on code in PR #43909:
URL: https://github.com/apache/superset/pull/43909#discussion_r3939706404


##########
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:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag the intentional handling of bare four-digit numeric strings as 
calendar years instead of epoch milliseconds; this narrow carve-out preserves 
four-digit year inputs.
   
   **Applied to:**
     - 
`superset-frontend/packages/superset-ui-core/src/time-format/utils/stringifyTimeInput.ts`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI 
Settings](https://app.codeant.ai/org/settings/learnings)*



-- 
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]

Reply via email to