Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ const cleanedCommentBody = computed(() => {
const dueDateLabel = computed(() => {
if (!props.activeTask?.due_date) return null;

return new Date(props.activeTask.due_date).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
timeZone: 'UTC',
});
return props.formatDate(props.activeTask.due_date);
});

const daysInColumnLabel = computed(() => {
Expand Down
7 changes: 2 additions & 5 deletions resources/js/components/tasks/TaskFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
X,
} from 'lucide-vue-next';
import { computed, reactive, watch } from 'vue';
import { formatDate } from '@/composables/useDateFormatter';

interface FilterState {
search: string;
Expand Down Expand Up @@ -157,11 +158,7 @@ const dueDateLabel = computed(() => {
return 'Any due date';
default:
try {
return new Date(localFilters.due_date).toLocaleDateString('en-US', {
day: 'numeric',
month: 'short',
year: 'numeric',
});
return formatDate(localFilters.due_date);
} catch {
return localFilters.due_date;
}
Expand Down
8 changes: 2 additions & 6 deletions resources/js/components/tasks/TaskItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { router } from '@inertiajs/vue3';
import { AlertTriangle, Calendar, Check, ClockAlert, MoreHorizontal, Pencil, Trash2 } from 'lucide-vue-next';
import { ref } from 'vue';
import { toast } from 'vue-sonner';
import { formatDate } from '@/composables/useDateFormatter';

const props = withDefaults(
defineProps<{
Expand Down Expand Up @@ -149,12 +150,7 @@ const deleteTask = () => {
>
<AlertTriangle v-if="!isDone && isOverdue(task)" class="size-3.5" />
<Calendar v-else class="size-3.5" />
<span>{{
new Date(task.due_date).toLocaleDateString(
'en-US',
{ year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' },
)
}}</span>
<span>{{ formatDate(task.due_date) }}</span>
</div>

<div
Expand Down
3 changes: 1 addition & 2 deletions resources/js/composables/useDateFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const formatDate = (value: string | null): string => {
const date = new Date(value);
if (Number.isNaN(date.getTime())) return 'No due date';

return dateTimeFormatter({ year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' }).format(date);
return dateTimeFormatter({ year: 'numeric', month: 'short', day: 'numeric' }).format(date);
};

export const formatDateTime = (value: string | null): string => {
Expand All @@ -22,6 +22,5 @@ export const formatDateTime = (value: string | null): string => {
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
timeZone: 'UTC',
}).format(date);
};
Loading