Skip to content

Add input for selecting date format for date converter#266

Merged
spring1843 merged 14 commits into
mainfrom
date-formats
Dec 20, 2025
Merged

Add input for selecting date format for date converter#266
spring1843 merged 14 commits into
mainfrom
date-formats

Conversation

@spring1843

@spring1843 spring1843 commented Dec 20, 2025

Copy link
Copy Markdown
Owner

Fixes: #91 and #90

…erter

Introduce an input format selector with options like Epoch, ISO, US, and EU formats. Enhance output by annotating each converted date with its specific pattern (e.g., YYYY-MM-DD).

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 1a4d0308-8145-4f5a-b2e4-caf2f388d8ec
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: c8b2a9d6-8f9d-4c0d-a311-b545d3188183
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/46062f4a-48c0-4bc7-8f40-e3917ba2ed87/1a4d0308-8145-4f5a-b2e4-caf2f388d8ec/pUBbH8b
Replit-Helium-Checkpoint-Created: true
Copilot AI review requested due to automatic review settings December 20, 2025 07:25
@netlify

netlify Bot commented Dec 20, 2025

Copy link
Copy Markdown

Deploy Preview for freedevtool ready!

Name Link
🔨 Latest commit 2fd6a27
🔍 Latest deploy log https://app.netlify.com/projects/freedevtool/deploys/694658c3861aca00098f2f99
😎 Deploy Preview https://deploy-preview-266--freedevtool.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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an input format selector to the Date Converter tool, allowing users to explicitly specify their input date format instead of relying solely on auto-detection. This improves usability when the auto-detect feature might be ambiguous (e.g., distinguishing between US and EU date formats like MM/DD/YYYY vs DD/MM/YYYY).

Key changes:

  • Added a Select dropdown for choosing input format (auto-detect, Unix seconds/milliseconds, ISO 8601, US format, EU format)
  • Enhanced the DateFormat interface with a pattern field to show format patterns alongside date examples
  • Updated date parsing logic to support format-specific parsing in addition to auto-detection
  • Improved UI layout with a responsive grid that places the date input and format selector side-by-side

Comment on lines +233 to +255
if (format === "us") {
// MM/DD/YYYY
const match = trimmed.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
if (!match) return null;
const [, m, d, y] = match.map(Number);
const date = new Date(y, m - 1, d);
if (date.getFullYear() !== y || date.getMonth() + 1 !== m || date.getDate() !== d) {
return null;
}
return date;
}

if (format === "eu") {
// DD/MM/YYYY
const match = trimmed.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
if (!match) return null;
const [, d, m, y] = match.map(Number);
const date = new Date(y, m - 1, d);
if (date.getFullYear() !== y || date.getMonth() + 1 !== m || date.getDate() !== d) {
return null;
}
return date;
}

Copilot AI Dec 20, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The date validation logic is duplicated between the US and EU format parsing. Consider extracting this validation into a helper function to reduce code duplication and improve maintainability.

For example, you could create a helper function like:

const validateDateComponents = (date: Date, year: number, month: number, day: number): boolean => {
  return date.getFullYear() === year && 
         date.getMonth() + 1 === month && 
         date.getDate() === day;
}

Then use it in both the US and EU format parsing branches.

Copilot uses AI. Check for mistakes.
spring1843 and others added 13 commits December 20, 2025 07:29
Add a new input format option "ISO 8601 Date (YYYY-MM-DD)" to the date converter's dropdown menu and implement parsing logic for this format.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 1a4d0308-8145-4f5a-b2e4-caf2f388d8ec
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: f0952440-2900-4ec5-8080-07ba155c82b0
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/46062f4a-48c0-4bc7-8f40-e3917ba2ed87/1a4d0308-8145-4f5a-b2e4-caf2f388d8ec/pUBbH8b
Replit-Helium-Checkpoint-Created: true
Adds several new date formats including RFC 822, RFC 850, RFC 1123, RFC 3339 Nano, ANSIC, Unix Date, and Ruby Date to the date converter tool.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 1a4d0308-8145-4f5a-b2e4-caf2f388d8ec
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 181a0c40-3290-4bdb-8705-eb436b41d355
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/46062f4a-48c0-4bc7-8f40-e3917ba2ed87/1a4d0308-8145-4f5a-b2e4-caf2f388d8ec/pUBbH8b
Replit-Helium-Checkpoint-Created: true
Update the date converter component to include new input formats like SQL, RFC 2822, RFC 3339, and human-readable text, along with enhanced descriptive labels for all existing and new input options.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 1a4d0308-8145-4f5a-b2e4-caf2f388d8ec
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: e475e187-e46b-46e3-8d9e-4bd563c74734
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/46062f4a-48c0-4bc7-8f40-e3917ba2ed87/1a4d0308-8145-4f5a-b2e4-caf2f388d8ec/pUBbH8b
Replit-Helium-Checkpoint-Created: true
Replicate and expand `parseInputDate` in `tests/lib/date-converter.test.ts` to include tests for various input formats, invalid leap dates, and new output formats, ensuring robust date parsing and formatting.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 1a4d0308-8145-4f5a-b2e4-caf2f388d8ec
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 8ad0da3b-e53a-44d7-8995-9f7a0ace29fe
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/46062f4a-48c0-4bc7-8f40-e3917ba2ed87/1a4d0308-8145-4f5a-b2e4-caf2f388d8ec/pUBbH8b
Replit-Helium-Checkpoint-Created: true
Implement Shamsi/Jalali input format parsing and output formatting, including conversion logic between Jalali and Gregorian calendars in the date converter component and its corresponding unit tests.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 1a4d0308-8145-4f5a-b2e4-caf2f388d8ec
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 514adcbd-2a5d-4536-abd0-89ffcee49905
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/46062f4a-48c0-4bc7-8f40-e3917ba2ed87/1a4d0308-8145-4f5a-b2e4-caf2f388d8ec/pUBbH8b
Replit-Helium-Checkpoint-Created: true
Expand `tests/lib/date-converter.test.ts` with 78 test cases covering parsing of various input formats, invalid date handling (including leap years), output formatting for all supported formats, and round-trip conversions.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 0fe4792c-c2a1-407f-8ccd-580d07d8aef7
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: baab5a17-7b33-4ead-b052-def6ec1bf84e
Replit-Helium-Checkpoint-Created: true
Remove auto-detect functionality from the date converter tool, defaulting to ISO 8601 and updating related UI and logic.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 981ef8b6-5d73-4016-ab04-e2484573a90c
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 8d865600-372a-4857-acfe-0c4fcd954756
Replit-Helium-Checkpoint-Created: true
Update the date converter to default to the Unix Epoch format instead of ISO 8601, and adjust the reset functionality accordingly.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 981ef8b6-5d73-4016-ab04-e2484573a90c
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: cf62f281-af01-4944-8f7a-249661e68636
Replit-Helium-Checkpoint-Created: true
@spring1843 spring1843 merged commit eca4026 into main Dec 20, 2025
5 checks passed
@spring1843 spring1843 deleted the date-formats branch December 20, 2025 08:10
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.

[Bug]: Incorrect interpretation of date format DD-MM-YYYY.

2 participants