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


##########
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:
   **Suggestion:** The four-digit check reinterprets valid epoch strings such 
as `1000` or `1970` as calendar years, changing their displayed dates from 
milliseconds after 1970. [incorrect condition logic]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=e408c83e0532472da7f880cb4d6d232a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=e408c83e0532472da7f880cb4d6d232a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/packages/superset-ui-core/src/time-format/utils/stringifyTimeInput.ts
   **Line:** 35:41
   **Comment:**
        *Incorrect Condition Logic: The four-digit check reinterprets valid 
epoch strings such as `1000` or `1970` as calendar years, changing their 
displayed dates from milliseconds after 1970.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43909&comment_hash=2b293fa4ad202961ac172c4c9832e6bfe5e4ee6fcb976d34001bbf98525e99b9&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43909&comment_hash=2b293fa4ad202961ac172c4c9832e6bfe5e4ee6fcb976d34001bbf98525e99b9&reaction=dislike'>๐Ÿ‘Ž</a>



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