diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte
index b230b28..be80984 100644
--- a/frontend/src/lib/components/AdventureCard.svelte
+++ b/frontend/src/lib/components/AdventureCard.svelte
@@ -163,7 +163,7 @@
{#if adventure.date && adventure.date !== ''}
-
{new Date(adventure.date).toLocaleDateString()}
+
{new Date(adventure.date).toLocaleDateString('en-US', { timeZone: 'UTC' })}
{/if}
{#if adventure.activity_types && adventure.activity_types.length > 0}
diff --git a/frontend/src/lib/components/CollectionCard.svelte b/frontend/src/lib/components/CollectionCard.svelte
index bb25110..948bd26 100644
--- a/frontend/src/lib/components/CollectionCard.svelte
+++ b/frontend/src/lib/components/CollectionCard.svelte
@@ -58,7 +58,7 @@
Duration: {Math.floor(
(new Date(collection.end_date).getTime() - new Date(collection.start_date).getTime()) /
(1000 * 60 * 60 * 24)
- )}{' '}
+ ) + 1}{' '}
days
{/if}
diff --git a/frontend/src/routes/collections/[id]/+page.svelte b/frontend/src/routes/collections/[id]/+page.svelte
index cc8500d..e3813a7 100644
--- a/frontend/src/routes/collections/[id]/+page.svelte
+++ b/frontend/src/routes/collections/[id]/+page.svelte
@@ -18,6 +18,8 @@
let adventures: Adventure[] = [];
let numVisited: number = 0;
+ let numberOfDays: number = NaN;
+
$: {
numVisited = adventures.filter((a) => a.type === 'visited').length;
}
@@ -32,12 +34,44 @@
} else {
notFound = true;
}
+ if (collection.start_date && collection.end_date) {
+ numberOfDays =
+ Math.floor(
+ (new Date(collection.end_date).getTime() - new Date(collection.start_date).getTime()) /
+ (1000 * 60 * 60 * 24)
+ ) + 1;
+ }
});
function deleteAdventure(event: CustomEvent
) {
adventures = adventures.filter((a) => a.id !== event.detail);
}
+ function groupAdventuresByDate(
+ adventures: Adventure[],
+ startDate: Date
+ ): Record {
+ const groupedAdventures: Record = {};
+
+ for (let i = 0; i < numberOfDays; i++) {
+ const currentDate = new Date(startDate);
+ currentDate.setDate(startDate.getDate() + i);
+ const dateString = currentDate.toISOString().split('T')[0];
+ groupedAdventures[dateString] = [];
+ }
+
+ adventures.forEach((adventure) => {
+ if (adventure.date) {
+ const adventureDate = new Date(adventure.date).toISOString().split('T')[0];
+ if (groupedAdventures[adventureDate]) {
+ groupedAdventures[adventureDate].push(adventure);
+ }
+ }
+ });
+
+ return groupedAdventures;
+ }
+
async function addAdventure(event: CustomEvent) {
console.log(event.detail);
if (adventures.find((a) => a.id === event.detail.id)) {
@@ -203,7 +237,44 @@
{/each}
- {#if collection.description}
-
+ Dates: {new Date(collection.start_date).toLocaleDateString('en-US', { timeZone: 'UTC' })} - {new Date(
+ collection.end_date
+ ).toLocaleDateString('en-US', { timeZone: 'UTC' })}
+
+
+ {#each Array(numberOfDays) as _, i}
+ {@const currentDate = new Date(collection.start_date)}
+ {@const temp = currentDate.setDate(currentDate.getDate() + i)}
+ {@const dateString = currentDate.toISOString().split('T')[0]}
+ {@const dayAdventures = groupAdventuresByDate(adventures, new Date(collection.start_date))[
+ dateString
+ ]}
+
+
+ {#each dayAdventures as adventure}
+
+ {/each}
+
+ {:else}
+ No adventures planned for this day.
+ {/if}
+ {/each}
{/if}
{/if}