Skip to content

feat(timestamp): rebuild as multi-mode developer utility - #49

Merged
ajithakdev merged 3 commits into
mainfrom
feat/timestamp-tool-overhaul
Sep 6, 2026
Merged

ajithakdev merged 3 commits into
mainfrom
feat/timestamp-tool-overhaul

Conversation

@ajithakdev

Copy link
Copy Markdown
Owner

Summary

Rebuilds the Timestamp tool from a single-field converter into a four-mode developer utility, then stabilises it with a focused bug-fix and polish pass.


What changed

🛠 feat — Four-mode Timestamp tool (TimestampTool.tsx)

Mode What it does
Convert Smart single-input parser (Unix s/ms, ISO 8601, RFC, any date string). Output grouped into three sections: Raw Unix, Standard UTC, Localized (timezone dropdown with pinned defaults + extensible list).
Batch Multiline textarea; regex-detects Unix timestamps and ISO 8601 strings in raw log paste; renders a table with original / ISO / relative columns. Handles mixed formats in the same paste.
Diff / Duration Two datetime inputs → live human-readable duration. Reverse mode: base datetime + offset expression (e.g. +1y 2mo 15d) → resulting datetime.
Cron Expression input with inline description, next-5-runs preview in selected timezone, per-run copy-to-clipboard.

Also included:

  • Session history sidebar (persisted to localStorage, max 10 entries) — replays any past convert / diff / cron back into the relevant tab on click.
  • Code snippet flyout on each value row: one-click copy for JS / Python / Go / Rust.
  • URL state sharing via useUrlState for all four modes (shareable links).
  • ✦ symbol on the Now button and the Unix Timestamp (seconds) label.
  • useToolStats wired up — usage counter increments on every successful copy (value rows + code snippets), consistent with ColorTool / CurlTool.

🐛 fix — History runaway on Convert tab

Root cause: parsedDate (a Date object) was listed as a useEffect dependency. Because parseSmartDate() returns new Date() on every render, and the component re-renders every second from the live-clock ticker (setTick), React treated it as changed every tick → the history useEffect fired every second → a new history entry was created for every clock tick even with no user input.

Fix: Removed all derived Date objects from the effect dependency array. Only primitive strings (convertInput, diffDate1, etc.) remain — these change only when the user types.


⚡ perf — Slow tab switching

Root cause: All four modes computed their full output on every 1-second render tick, regardless of which tab was active. getNextCronRuns(), the batch regex loop, and three parseSmartDate calls for diff ran unconditionally every second.

Fix: Each computation is now gated behind activeMode === '...'. On the Convert tab, only parseSmartDate(convertInput) runs per tick. Cron, Batch, and Diff are no-ops until you switch to their tab.


💅 fix — Dropdown, Toast, and shell polish (Field.tsx, Toast.tsx, index.css)

  • Dropdown horizontal scrollbar eliminated: overflowX: hidden on the listbox, text-overflow: ellipsis + white-space: nowrap on item labels, title tooltip for full name on hover.
  • Dropdown z-index raised 100 → 500 so the listbox floats above the history sidebar.
  • Toast gets left: auto + maxWidth: calc(100vw - 32px) so it never clips on narrow viewports.
  • index.css overflow-x: hidden on html/body/#root to suppress stray horizontal scrollbar from absolutely-positioned elements.

Testing checklist

  • Convert tab: live values update but history does not grow unless input changes
  • Batch tab: paste mixed log lines, table renders with all matches
  • Diff tab: duration computes correctly; offset reverse mode works
  • Cron tab: next-5-runs preview refreshes on expression change; timezone dropdown has no horizontal scroll
  • Tab switching feels instant at 100% zoom
  • Usage count increments (footer) on any copy action
  • Toast appears within viewport on narrow screens
  • Shareable URL preserves mode + inputs on reload

@netlify

netlify Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for toolglass-by-ajithakdev ready!

Name Link
🔨 Latest commit 4869605
🔍 Latest deploy log https://app.netlify.com/projects/toolglass-by-ajithakdev/deploys/6a54a5369a5a880008cd5ad4
😎 Deploy Preview https://deploy-preview-49--toolglass-by-ajithakdev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Transforms the single-converter timestamp tool into a full four-mode
developer utility with a shared session history drawer.

Modes:
- Convert: smart single-input parser (seconds/ms/ISO/RFC) with grouped
  output sections — Raw Unix, Standard UTC, and Localized (timezone
  dropdown with pinned defaults + extensible list).
- Batch: multiline textarea; regex-detects Unix timestamps and ISO 8601
  strings in raw log paste; renders results as a sortable table with
  original, ISO, and relative columns.
- Diff/Duration: two datetime inputs → live human-readable duration;
  reverse mode (base datetime + offset expression → resulting datetime).
- Cron: expression input with live description, next-5-runs preview in
  selected timezone, and copy-to-clipboard per run.

Other additions:
- Session history sidebar (persisted to localStorage, max 10 entries)
  that replays any past convert/diff/cron into the relevant tab.
- Code snippet flyout on each value row (JS/Python/Go/Rust snippets).
- URL state sharing via useUrlState for all four modes.
- ✦ symbol on Now button and Unix Timestamp label for visual identity.
- useToolStats wired up: usage counter increments on every copy action.
Dropdown (Field.tsx):
- Add overflowX: hidden to listbox container — eliminates horizontal
  scrollbar that appeared with long timezone names (e.g. America/Sao_Paulo).
- Wrap item label in a flex span with white-space:nowrap + text-overflow:
  ellipsis so long entries truncate cleanly without reflowing the list.
- Add title={opt.label} tooltip so full name is readable on hover.
- Raise listbox z-index from 100 → 500 so it floats above the history
  sidebar panel without overlap.

Toast (Toast.tsx):
- Set left: auto and maxWidth: calc(100vw - 32px) on the container so
  toasts never clip or overflow on narrow viewports.

index.css:
- Add overflow-x: hidden to html/body/#root to suppress any stray
  horizontal scrollbar introduced by absolutely-positioned elements.
@ajithakdev
ajithakdev force-pushed the feat/timestamp-tool-overhaul branch from 4869605 to 52b9191 Compare September 6, 2026 14:44
@netlify

netlify Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for toolglass-by-ajithakdev ready!

Name Link
🔨 Latest commit 52b9191
🔍 Latest deploy log https://app.netlify.com/projects/toolglass-by-ajithakdev/deploys/6a9d7c684d5aaa000986a9b1
😎 Deploy Preview https://deploy-preview-49--toolglass-by-ajithakdev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ajithakdev
ajithakdev merged commit 3fac546 into main Sep 6, 2026
7 checks passed
@ajithakdev
ajithakdev deleted the feat/timestamp-tool-overhaul branch September 6, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant