diff --git a/app/assignment/viewDetailsAssignment.tsx b/app/assignment/viewDetailsAssignment.tsx
index 183498c..7f99ac7 100644
--- a/app/assignment/viewDetailsAssignment.tsx
+++ b/app/assignment/viewDetailsAssignment.tsx
@@ -1,3 +1,4 @@
+import { formatDateTime } from '@/lib/date';
import { CheckAssignmentCompletion, CheckSubjectCompletion } from '@/lib/progress';
import { getSubjectColorSet, type SubjectColor } from '@/lib/subjectColors';
import { supabase } from '@/lib/supabase';
@@ -287,19 +288,7 @@ export default function ViewDetailsAssignment() {
- Deadline: {assignment.deadline || 'No deadline'}
-
-
-
-
-
- {assignment.isCompleted ? 'Completed' : 'In progress'}
+ Deadline: {formatDateTime(assignment.deadline) || 'No deadline'}
@@ -332,9 +321,9 @@ export default function ViewDetailsAssignment() {
-
- Last changed: {assignment.lastChanged}
-
+
+ Last changed: {formatDateTime(assignment.lastChanged)}
+
diff --git a/app/subject/viewDetailsSubject.tsx b/app/subject/viewDetailsSubject.tsx
index 6820a7c..a815f02 100644
--- a/app/subject/viewDetailsSubject.tsx
+++ b/app/subject/viewDetailsSubject.tsx
@@ -1,3 +1,4 @@
+import { formatDate, formatDateTime } from '@/lib/date';
import { CheckSubjectCompletion } from '@/lib/progress';
import { SUBJECT_COLORS, type SubjectColor } from '@/lib/subjectColors';
import { supabase } from '@/lib/supabase';
@@ -17,37 +18,6 @@ export type Subject = {
color: SubjectColor;
};
-
-const formatDate = (value?: string | null) => {
- if (!value) return 'No date';
-
- const date = new Date(value);
-
- if (Number.isNaN(date.getTime())) return value;
-
- return date.toLocaleDateString(undefined, {
- year: 'numeric',
- month: 'short',
- day: 'numeric',
- });
-};
-
-const formatDateTime = (value?: string | null) => {
- if (!value) return 'Unknown';
-
- const date = new Date(value);
-
- if (Number.isNaN(date.getTime())) return value;
-
- return date.toLocaleString(undefined, {
- year: 'numeric',
- month: 'short',
- day: 'numeric',
- hour: 'numeric',
- minute: '2-digit',
- });
-};
-
export default function ViewDetailsSubject() {
const { sId } = useLocalSearchParams<{ sId: string }>();
const [subject, SetSubject] = useState(null);
diff --git a/lib/date.ts b/lib/date.ts
new file mode 100644
index 0000000..a21a5fb
--- /dev/null
+++ b/lib/date.ts
@@ -0,0 +1,29 @@
+export const formatDate = (value?: string | null) => {
+ if (!value) return 'No date';
+
+ const date = new Date(value);
+
+ if (Number.isNaN(date.getTime())) return value;
+
+ return date.toLocaleDateString(undefined, {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric',
+ });
+};
+
+export const formatDateTime = (value?: string | null) => {
+ if (!value) return 'Unknown';
+
+ const date = new Date(value);
+
+ if (Number.isNaN(date.getTime())) return value;
+
+ return date.toLocaleString(undefined, {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric',
+ hour: 'numeric',
+ minute: '2-digit',
+ });
+};
\ No newline at end of file