mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-23 14:59:36 +02:00
Update date validation to use UTC comparison and enhance documentation
This commit is contained in:
parent
f15d7bfd1e
commit
890332f4b6
2 changed files with 9 additions and 8 deletions
|
@ -366,8 +366,8 @@
|
|||
</div>
|
||||
|
||||
<!-- Validation Message -->
|
||||
{#if !validateDateRange(localStartDate, localEndDate).valid}
|
||||
<div role="alert" class="alert alert-error">
|
||||
{#if !validateDateRange(utcStartDate ?? '', utcEndDate ?? '').valid}
|
||||
<div role="alert" class="alert alert-error mt-2">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-6 w-6 shrink-0 stroke-current"
|
||||
|
|
|
@ -87,10 +87,10 @@ export function updateUTCDate({
|
|||
}
|
||||
|
||||
/**
|
||||
* Validate date ranges
|
||||
* @param startDate - Start date string
|
||||
* @param endDate - End date string
|
||||
* @returns Object with validation result and error message
|
||||
* Validate date ranges using UTC comparison
|
||||
* @param startDate - Start date string in UTC (ISO format)
|
||||
* @param endDate - End date string in UTC (ISO format)
|
||||
* @returns Object with validation result and optional error message
|
||||
*/
|
||||
export function validateDateRange(
|
||||
startDate: string,
|
||||
|
@ -106,11 +106,12 @@ export function validateDateRange(
|
|||
if (
|
||||
startDate &&
|
||||
endDate &&
|
||||
DateTime.fromISO(startDate).toMillis() > DateTime.fromISO(endDate).toMillis()
|
||||
DateTime.fromISO(startDate, { zone: 'utc' }).toMillis() >
|
||||
DateTime.fromISO(endDate, { zone: 'utc' }).toMillis()
|
||||
) {
|
||||
return {
|
||||
valid: false,
|
||||
error: 'Start date must be before end date'
|
||||
error: 'Start date must be before end date (based on UTC)'
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue