Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
346 changes: 173 additions & 173 deletions composer.lock

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions resources/js/Mixins/Global.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,18 @@ export default {
}
},
formatDate(timestamp) {
if (!timestamp) {
return "";
}
const date = new Date(timestamp);
return new Intl.DateTimeFormat("default", {
dateStyle: "long",
}).format(date);
},
formatDateTime(timestamp) {
if (!timestamp) {
return "";
}
const date = new Date(timestamp);
return new Intl.DateTimeFormat("en", {
dateStyle: "full",
Expand All @@ -175,6 +181,58 @@ export default {
timeStyle: "short",
}).format(date);
},

/**
* Date-only formatting in UTC (prevents off-by-one day shifts for Zulu timestamps).
*/
formatUtcDate(timestamp) {
if (!timestamp) {
return "";
}

const date = new Date(timestamp);

return date.toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
timeZone: "UTC",
});
},

/**
* Short, date-only formatting (used in compact cards/sidebars).
*/
formatShortDate(timestamp) {
if (!timestamp) {
return "";
}

const date = new Date(timestamp);

return date.toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
});
},

/**
* UTC variant of formatRecordTimestamp (keeps date+time style but fixes timezone shifts).
*/
formatRecordTimestampUtc(timestamp) {
if (!timestamp) {
return "";
}

const date = new Date(timestamp);

return new Intl.DateTimeFormat(undefined, {
dateStyle: "medium",
timeStyle: "short",
timeZone: "UTC",
}).format(date);
},
md(data) {
if (!data) return "";

Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/Project/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
class="tabular-nums text-amber-900 dark:text-amber-50"
>
{{
formatRecordTimestamp(
formatRecordTimestampUtc(
project.release_date
)
}}
Expand Down
24 changes: 1 addition & 23 deletions resources/js/Pages/Public/Project/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<strong
class="font-semibold text-teal-950 dark:text-teal-50"
>{{
formatDate(dashboardProject.release_date)
formatUtcDate(dashboardProject.release_date)
}}</strong
>.
<button
Expand Down Expand Up @@ -1556,28 +1556,6 @@ export default {
})
.join(" ");
},

/**
* Format date for display in project metadata
*
* Converts ISO date strings to human-readable format
* suitable for displaying creation and publication dates.
*
* @param {String} dateString - ISO date string
* @returns {String} Formatted date string
*/
formatDate(dateString) {
if (!dateString) return "";

const date = new Date(dateString);
const options = {
year: "numeric",
month: "long",
day: "numeric",
};

return date.toLocaleDateString("en-US", options);
},
},
};
</script>
16 changes: 2 additions & 14 deletions resources/js/Pages/Public/Project/Show.vue
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
class="mt-2 text-sm font-medium text-gray-800 dark:text-gray-200"
>
{{
formatDate(
formatShortDate(
(project.data &&
project.data.release_date) ||
project.release_date
Expand All @@ -380,7 +380,7 @@
class="mt-2 text-sm font-medium text-gray-800 dark:text-gray-200"
>
{{
formatDate(
formatShortDate(
(project.data &&
project.data.created_at) ||
project.created_at
Expand Down Expand Up @@ -596,18 +596,6 @@ export default {
},

methods: {
formatDate(value) {
if (!value) {
return "";
}
const d = new Date(value);

return d.toLocaleDateString(undefined, {
year: "numeric",
month: "short",
day: "numeric",
});
},
toggleDetails() {
this.$refs.projectDetailsElement?.toggleDetails();
},
Expand Down
20 changes: 1 addition & 19 deletions resources/js/Pages/Study/Files.vue
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@
class="text-sm text-gray-500"
>
{{
formatDate(
formatRecordTimestamp(
file.updated_at ||
file.created_at
)
Expand Down Expand Up @@ -921,25 +921,7 @@ export default {
this.viewMode = mode;
localStorage.setItem("nmrxiv-files-view-mode", mode);
},
formatDate(dateString) {
if (!dateString) return "--";

const date = new Date(dateString);

const options = {
day: "numeric",
month: "short",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
};

// Format like "18. Aug 2025 at 10:52"
return date
.toLocaleDateString("en-GB", options)
.replace(",", " at")
.replace(/(\d+)/, "$1.");
},
sortFiles(column) {
if (this.sortBy === column) {
// Toggle sort order if clicking the same column
Expand Down
24 changes: 1 addition & 23 deletions resources/js/Shared/FileSystemBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@
class="text-sm text-gray-500"
>
{{
formatDate(
formatRecordTimestamp(
file.updated_at ||
file.created_at
)
Expand Down Expand Up @@ -4044,28 +4044,6 @@ export default {
}
},

/**
* Format date for display
*/
formatDate(dateString) {
if (!dateString) return "--";

const date = new Date(dateString);
const options = {
day: "numeric",
month: "short",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
};

// Format like "18. Aug 2025 at 10:52"
return date
.toLocaleDateString("en-GB", options)
.replace(",", " at")
.replace(/(\d+)/, "$1.");
},

/**
* Get download URL for individual files
*/
Expand Down
18 changes: 2 additions & 16 deletions resources/js/Shared/ProjectCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
</p>
<p class="mt-0.5 text-xs text-gray-500">
<time :datetime="project.created_at">
{{ formatDate(project.created_at) }}
{{ formatShortDate(project.created_at) }}
</time>
</p>
<p
Expand Down Expand Up @@ -329,7 +329,7 @@
/>
</svg>
<time :datetime="project.created_at">
{{ formatDate(project.created_at) }}
{{ formatShortDate(project.created_at) }}
</time>
</p>
</div>
Expand Down Expand Up @@ -425,20 +425,6 @@ export default {
this.$inertia.visit(route("login"));
}
},

formatDate(dateString) {
if (!dateString) {
return "";
}

const date = new Date(dateString);

return date.toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
});
},
},
};
</script>
12 changes: 0 additions & 12 deletions resources/js/Shared/StudyCardPublic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -347,18 +347,6 @@ export default {
* @param {String} dateString - ISO date string
* @returns {String} Formatted date string
*/
formatDate(dateString) {
if (!dateString) return "";

const date = new Date(dateString);
const options = {
year: "numeric",
month: "long",
day: "numeric",
};

return date.toLocaleDateString("en-US", options);
},
},
};
</script>
Loading