Skip to content

Commit e433aa7

Browse files
committed
fix: improve datetime visibility on mobile screens
1 parent e87b819 commit e433aa7

3 files changed

Lines changed: 87 additions & 8 deletions

File tree

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ <h2 class="lobster text-center mb-2">
269269
class="form-control"
270270
id="task-time"
271271
name="task-time"
272+
placeholder="m/d/y - 00:00:00"
272273
/>
273274
<p class="invalid-feedback d-none">
274275
Please select a date and time.

js/app.js

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,12 +1106,52 @@ function showTaskLists(tasks) {
11061106
function formatDateTime(dateTime) {
11071107
if (!dateTime) return "";
11081108

1109-
const date = new Date(dateTime);
1110-
return date.toLocaleString(undefined, {
1111-
hour: "2-digit",
1112-
minute: "2-digit",
1113-
day: "2-digit",
1114-
month: "2-digit",
1115-
year: "numeric",
1116-
});
1109+
try {
1110+
const date = new Date(dateTime);
1111+
if (isNaN(date.getTime())) return "";
1112+
1113+
const now = new Date();
1114+
const isToday = date.toDateString() === now.toDateString();
1115+
const isThisYear = date.getFullYear() === now.getFullYear();
1116+
1117+
// Check if mobile screen
1118+
const isMobile = window.innerWidth <= 576;
1119+
1120+
if (isMobile) {
1121+
// Compact format for mobile: "Today 2:30 PM" or "Jan 15, 2:30 PM"
1122+
if (isToday) {
1123+
return `Today ${date.toLocaleTimeString(undefined, {
1124+
hour: "2-digit",
1125+
minute: "2-digit",
1126+
})}`;
1127+
} else if (isThisYear) {
1128+
return date.toLocaleDateString(undefined, {
1129+
month: "short",
1130+
day: "numeric",
1131+
hour: "2-digit",
1132+
minute: "2-digit",
1133+
});
1134+
} else {
1135+
return date.toLocaleDateString(undefined, {
1136+
month: "short",
1137+
day: "numeric",
1138+
year: "2-digit",
1139+
hour: "2-digit",
1140+
minute: "2-digit",
1141+
});
1142+
}
1143+
} else {
1144+
// Full format for desktop
1145+
return date.toLocaleString(undefined, {
1146+
hour: "2-digit",
1147+
minute: "2-digit",
1148+
day: "2-digit",
1149+
month: "2-digit",
1150+
year: "numeric",
1151+
});
1152+
}
1153+
} catch (error) {
1154+
console.error("Error formatting datetime:", error);
1155+
return "";
1156+
}
11171157
}

style.css

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,37 @@ main > .container {
294294
.tasks-filters {
295295
justify-content: flex-start !important;
296296
}
297+
298+
/* Ensure datetime is visible on mobile */
299+
.time-label {
300+
font-size: 0.8rem !important;
301+
word-break: break-word;
302+
text-align: right;
303+
white-space: normal;
304+
line-height: 1.3;
305+
width: 100%;
306+
margin-top: 0.5rem;
307+
}
308+
309+
/* Adjust wrapper layout on mobile */
310+
.custom-list-item .wrapper {
311+
flex-wrap: wrap;
312+
}
313+
314+
.custom-list-item .wrapper .content {
315+
flex: 1 1 100%;
316+
min-width: 0;
317+
}
318+
319+
.custom-list-item .wrapper .actions {
320+
flex: 0 0 auto;
321+
}
322+
323+
/* Ensure datetime-local input is visible on mobile */
324+
#task-time {
325+
font-size: 1rem !important;
326+
min-height: 44px; /* iOS touch target size */
327+
}
297328
}
298329

299330
.task-weekly-summary {
@@ -381,6 +412,13 @@ main > .container {
381412
.custom-list-item.task-completed .time-label {
382413
color: var(--time-label-color);
383414
}
415+
416+
/* Ensure time label is always visible */
417+
.time-label {
418+
min-width: 0; /* Allow flex shrinking */
419+
flex-shrink: 1;
420+
overflow: visible;
421+
}
384422
.task-complete-btn {
385423
display: inline-flex;
386424
align-items: center;

0 commit comments

Comments
 (0)