Skip to content

Commit

Permalink
consolidate date handling, reuse updated formatDate util
Browse files Browse the repository at this point in the history
  • Loading branch information
dannon committed Dec 16, 2024
1 parent 2b52c6f commit 47777c7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 1 addition & 5 deletions website/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { ref, computed } from "vue";
import { type Workflow, type WorkflowCollection } from "~/models/workflow";
import { useWorkflowStore } from "~/stores/workflows";
import { formatDate } from "~/utils/";
const searchQuery = ref("");
const selectedWorkflow = ref<Workflow | null>(null);
Expand Down Expand Up @@ -36,11 +37,6 @@ function selectWorkflow(workflow: Workflow) {
selectedWorkflow.value = workflow;
scrollToWorkflow(workflow);
}
function formatDate(isoString: string): string {
const date = new Date(isoString);
return date.toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" });
}
</script>

<template>
Expand Down
10 changes: 2 additions & 8 deletions website/pages/workflow/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ import { useRoute } from "vue-router";
import MarkdownRenderer from "~/components/MarkdownRenderer.vue";
import Author from "~/components/Author.vue";
import { useWorkflowStore } from "~/stores/workflows";
import { formatDate } from "~/utils/";
const route = useRoute();
const workflowStore = useWorkflowStore();
const workflow = computed(() => workflowStore.workflow);
const formatDate = (date: string) => {
return new Date(date).toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
});
};
// TODO: Add a component for authors. For now, just have a computed that grabs names and joins them
const authors = computed(() => {
let authorLine = "";
Expand Down Expand Up @@ -143,6 +136,7 @@ const onInstanceChange = (value: string) => {
<Author :author="author" />
</li>
<li><strong>Release:</strong> {{ workflow.definition.release }}</li>
<li><strong>Updated:</strong> {{ formatDate(workflow.updated) }}</li>
<li><strong>License:</strong> {{ workflow.definition.license }}</li>
<li><strong>UniqueID:</strong> {{ workflow.definition.uuid }}</li>
</ul>
Expand Down
10 changes: 10 additions & 0 deletions website/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Formats an ISO timestamp into a readable date string.
*
* @param isoString - The ISO timestamp string to format.
* @returns A formatted date string in the format "Month Day, Year".
*/
export function formatDate(isoString: string): string {
const date = new Date(isoString);
return date.toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" });
}

0 comments on commit 47777c7

Please sign in to comment.