Diff
checker
Text
Text
Images
Documents
Excel
Folders
Legal
Enterprise
Desktop
Pricing
Sign in
Download Diffchecker Desktop
Compare text
Find the difference between two text files
Tools
History
Real-time editor
Hide whitespace changes
Hide unchanged lines
Disable line wrap
Layout
Split
Unified
Diff precision
Smart
Word
Char
Text styles
Change appearance
Syntax highlighting
Choose syntax
Ignore
Transform text
Go to first change
Edit input
Diffchecker Desktop
The most secure way to run Diffchecker. Get the Diffchecker Desktop app: your diffs never leave your computer!
Get Desktop
Gantt Date Normalization
Created
3 months ago
Diff never expires
Clear
Export
Share
Explain
2 removals
Lines
Total
Removed
Characters
Total
Removed
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
18 lines
Copy
45 additions
Lines
Total
Added
Characters
Total
Added
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
57 lines
Copy
/**
/**
* Stable date conversion helpers for Gantt ↔ Supabase round-trips.
* Stable date conversion helpers for Gantt ↔ Supabase round-trips.
*
*
* The Gantt component works with JS Date objects.
* The Gantt component works with JS Date objects.
* Supabase stores timestamptz as ISO-8601 strings.
* Supabase stores timestamptz as ISO-8601 strings.
*/
*/
Copy
Copied
Copy
Copied
/** Convert a JS Date
to an ISO-8601 string for Supabase. */
export function dateToISO(d: Date |
null | undefined): string | null {
function parseGanttDateString(value: string): Date | null {
if (!d) return null;
const match = value.match(
return
d
.toISOString();
/^(\d{2})-(\d{2})-(\d{4})(?:\s+(\d{2}):(\d{2})(?::(\d{2}))?)?$/,
);
if (!match) return null;
const [, day, month, year, hours = "00", minutes = "00", seconds = "00"] = match;
const date = new Date(
Number(year),
Number(month) - 1,
Number(day),
Number(hours),
Number(minutes),
Number(seconds),
);
return Number.isNaN(date.getTime()) ? null : date;
}
/** Convert a JS Date
or supported Gantt string
to an ISO-8601 string for Supabase. */
export function dateToISO(d: Date |
string |
null | undefined): string | null {
if (!d) return null;
if (d instanceof Date) {
return Number.isNaN(d.getTime()) ? null : d.toISOString();
}
if (typeof d === "string") {
const parsed = parseGanttDateString(d) ?? new Date(d);
return
Number.isNaN(parsed.getTime()) ? null : parsed
.toISOString();
}
return null;
}
}
Copy
Copied
Copy
Copied
/** Convert an ISO-8601 string (or null) to a JS Date for Gantt. */
/** Convert an ISO-8601 string (or null) to a JS Date for Gantt. */
export function isoToDate(s: string | null | undefined): Date {
export function isoToDate(s: string | null | undefined): Date {
if (!s) return new Date();
if (!s) return new Date();
return new Date(s);
return new Date(s);
}
}
Saved diffs
Original text
Open file
/** * Stable date conversion helpers for Gantt ↔ Supabase round-trips. * * The Gantt component works with JS Date objects. * Supabase stores timestamptz as ISO-8601 strings. */ /** Convert a JS Date to an ISO-8601 string for Supabase. */ export function dateToISO(d: Date | null | undefined): string | null { if (!d) return null; return d.toISOString(); } /** Convert an ISO-8601 string (or null) to a JS Date for Gantt. */ export function isoToDate(s: string | null | undefined): Date { if (!s) return new Date(); return new Date(s); }
Changed text
Open file
/** * Stable date conversion helpers for Gantt ↔ Supabase round-trips. * * The Gantt component works with JS Date objects. * Supabase stores timestamptz as ISO-8601 strings. */ function parseGanttDateString(value: string): Date | null { const match = value.match( /^(\d{2})-(\d{2})-(\d{4})(?:\s+(\d{2}):(\d{2})(?::(\d{2}))?)?$/, ); if (!match) return null; const [, day, month, year, hours = "00", minutes = "00", seconds = "00"] = match; const date = new Date( Number(year), Number(month) - 1, Number(day), Number(hours), Number(minutes), Number(seconds), ); return Number.isNaN(date.getTime()) ? null : date; } /** Convert a JS Date or supported Gantt string to an ISO-8601 string for Supabase. */ export function dateToISO(d: Date | string | null | undefined): string | null { if (!d) return null; if (d instanceof Date) { return Number.isNaN(d.getTime()) ? null : d.toISOString(); } if (typeof d === "string") { const parsed = parseGanttDateString(d) ?? new Date(d); return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString(); } return null; } /** Convert an ISO-8601 string (or null) to a JS Date for Gantt. */ export function isoToDate(s: string | null | undefined): Date { if (!s) return new Date(); return new Date(s); }
Find difference