-
Notifications
You must be signed in to change notification settings - Fork 16
feat: Add Unix Timestamp (Epoch) Converter Utility #28
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,207 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "use client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import React, { useState, useEffect } from "react"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Button, Input, DatePicker, message, Tooltip, Card, Typography, Space, Row, Col, ConfigProvider, theme } from "antd"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import dayjs, { Dayjs } from "dayjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import relativeTime from "dayjs/plugin/relativeTime"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import utc from "dayjs/plugin/utc"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import timezone from "dayjs/plugin/timezone"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import DevelopmentToolsStyles from "../../developmentToolsStyles.module.scss"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { CopyOutlined, ReloadOutlined, DeleteOutlined } from "@ant-design/icons"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| import { CopyOutlined, ReloadOutlined, DeleteOutlined } from "@ant-design/icons"; | |
| import { ReloadOutlined, DeleteOutlined } from "@ant-design/icons"; |
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dayjs/plugin/timezone is imported, but the component doesn’t use .tz() anywhere. If timezone conversion isn’t needed, consider removing the timezone plugin import/usage to reduce bundle size.
| import timezone from "dayjs/plugin/timezone"; | |
| import DevelopmentToolsStyles from "../../developmentToolsStyles.module.scss"; | |
| import { CopyOutlined, ReloadOutlined, DeleteOutlined } from "@ant-design/icons"; | |
| dayjs.extend(relativeTime); | |
| dayjs.extend(utc); | |
| dayjs.extend(timezone); | |
| import DevelopmentToolsStyles from "../../developmentToolsStyles.module.scss"; | |
| import { CopyOutlined, ReloadOutlined, DeleteOutlined } from "@ant-design/icons"; | |
| dayjs.extend(relativeTime); | |
| dayjs.extend(utc); |
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dayjs.extend(timezone) is currently unused since the component doesn’t call .tz(). Consider dropping this extend call (and the plugin import) unless you plan to add explicit timezone selection/conversion.
| import timezone from "dayjs/plugin/timezone"; | |
| import DevelopmentToolsStyles from "../../developmentToolsStyles.module.scss"; | |
| import { CopyOutlined, ReloadOutlined, DeleteOutlined } from "@ant-design/icons"; | |
| dayjs.extend(relativeTime); | |
| dayjs.extend(utc); | |
| dayjs.extend(timezone); | |
| import DevelopmentToolsStyles from "../../developmentToolsStyles.module.scss"; | |
| import { CopyOutlined, ReloadOutlined, DeleteOutlined } from "@ant-design/icons"; | |
| dayjs.extend(relativeTime); | |
| dayjs.extend(utc); |
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Title is destructured from Typography but not used. Please remove it (or render a heading with it) to avoid unused-variable lint errors.
| const { Title, Text } = Typography; | |
| const { Text } = Typography; |
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description mentions auto-detecting seconds vs milliseconds, and this block’s comment suggests a heuristic, but the implementation always relies on the current isMilliseconds toggle and never updates it based on the input size. Either implement the heuristic (e.g., switch to ms for 13-digit values / >1e11) or update/remove the comment and PR description to match the actual behavior.
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user enters a non-numeric timestamp (e.g. abc), timestamp updates but date is left unchanged, so the DatePicker can show a stale value while the output says "Invalid Timestamp". Consider setting date to null (or otherwise clearing/invalidating it) when Number(val) is NaN to keep the two inputs consistent.
| setDate(dayjs(timestampInMs)); | |
| setDate(dayjs(timestampInMs)); | |
| } else { | |
| // Clear date when timestamp is non-numeric to avoid stale DatePicker value | |
| setDate(null); |
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyToClipboard is currently unused (the UI uses Text's copyable prop instead). Please remove this helper (or switch the UI to call it) to avoid unused-function lint errors and potential unhandled clipboard promise rejections.
| const copyToClipboard = (text: string) => { | |
| navigator.clipboard.writeText(text); | |
| message.success("Copied to clipboard!"); | |
| }; |
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With strict: true, currentDayjs is typed as Dayjs | null, but later it’s used as non-null (currentDayjs.format(), utc(), etc.). This will cause TypeScript errors; consider restructuring to explicitly guard (if (!currentDayjs || !currentDayjs.isValid()) ...) so TS can narrow the type in the render branch (or use a non-null assertion if you’re certain).
| const currentDayjs = timestamp ? dayjs(isMilliseconds ? Number(timestamp) : Number(timestamp) * 1000) : null; | |
| const isValid = currentDayjs && currentDayjs.isValid(); | |
| const num = timestamp ? Number(timestamp) : NaN; | |
| const currentDayjs = dayjs(isMilliseconds ? num : num * 1000); | |
| const isValid = !!timestamp && !Number.isNaN(num) && currentDayjs.isValid(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused imports here (
useEffectand several AntD exports likeTooltip/Card) should be removed to avoidnext lintfailures. Please trim the import list to only what the component uses.