forge
Explore
Log in

Don't you dare go Hollow

iz: a passed clock makes a card overdue

Browse files at this commit

f6d1487f71b1692a7714f17e8558b5d989876771Ahmet Kaan GümüşParent: 3388b14
Overdue was day-grain only, so a clock that had already passed still read as on time. The card, the filter count, and the detail now share one decision: the instant has to be reached, and today with no clock is still not overdue.
crates/iz-core/src/board.rsmodified+298 -12
@@ -178,12 +178,11 @@ impl TaskCard {
178178 !self.is_done() && !self.blocked_by.is_empty()
179179 }
180180
181- /// Past its deadline and not finished. A deadline of today is not overdue.
182- pub fn is_overdue(&self, today: Date) -> bool {
183- match self.deadline {
184- Some(day) => !self.is_done() && day < today,
185- None => false,
186- }
181+ /// Past its deadline and not finished — the shared
182+ /// [`deadline_is_overdue`] decision, so a passed clock counts here even
183+ /// though the card shows the clock rather than the day.
184+ pub fn is_overdue(&self, now: OffsetDateTime) -> bool {
185+ deadline_is_overdue(self.is_done(), self.deadline, self.clock_at, now)
187186 }
188187
189188 pub fn is_assigned_to(&self, user_id: &str) -> bool {
@@ -194,12 +193,14 @@ impl TaskCard {
194193 /// `Aug 21 · overdue`, `done Aug 14` or `no deadline`. English-only —
195194 /// kept for callers (mail, tests) that want the baked sentence; UI
196195 /// rendering should use [`TaskCard::deadline_parts`] and translate.
197- pub fn deadline_label(&self, today: Date) -> String {
196+ pub fn deadline_label(&self, now: OffsetDateTime) -> String {
198197 if let Some(done) = self.done_at {
199198 return format!("done {}", day_label(done.date()));
200199 }
201200 match self.deadline {
202- Some(day) if day < today => format!("{} · overdue", day_label(day)),
201+ Some(day) if deadline_is_overdue(false, Some(day), self.clock_at, now) => {
202+ format!("{} · overdue", day_label(day))
203+ }
203204 Some(day) => day_label(day),
204205 None => "no deadline".to_string(),
205206 }
@@ -208,7 +209,7 @@ impl TaskCard {
208209 /// The same chip as [`TaskCard::deadline_label`], split into a
209210 /// language-free date string and a state the caller translates.
210211 /// `None` when there's nothing to show (no deadline, not done).
211- pub fn deadline_parts(&self, today: Date) -> Option<DeadlineParts> {
212+ pub fn deadline_parts(&self, now: OffsetDateTime) -> Option<DeadlineParts> {
212213 if let Some(done) = self.done_at {
213214 return Some(DeadlineParts {
214215 date: day_label(done.date()),
@@ -217,7 +218,7 @@ impl TaskCard {
217218 }
218219 self.deadline.map(|day| DeadlineParts {
219220 date: day_label(day),
220- state: if day < today {
221+ state: if deadline_is_overdue(false, Some(day), self.clock_at, now) {
221222 DeadlineState::Overdue
222223 } else {
223224 DeadlineState::OnTime
@@ -241,6 +242,25 @@ pub enum DeadlineState {
241242 Done,
242243 }
243244
245+/// The one overdue decision behind the card, the filter count and the task
246+/// detail. Done is never overdue. A clock beats the day: the instant itself
247+/// has to be reached — including a past day whose clock is still ahead. With
248+/// only a day, the day has to be strictly past; today is not overdue yet.
249+pub fn deadline_is_overdue(
250+ done: bool,
251+ deadline: Option<Date>,
252+ clock_at: Option<OffsetDateTime>,
253+ now: OffsetDateTime,
254+) -> bool {
255+ if done {
256+ return false;
257+ }
258+ match clock_at {
259+ Some(at) => at <= now,
260+ None => deadline.is_some_and(|day| day < now.date()),
261+ }
262+}
263+
244264 /// A column with its cards already in it.
245265 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
246266 pub struct ColumnView {
@@ -269,8 +289,8 @@ impl BoardView {
269289 }
270290
271291 /// The `1 overdue` chip in the filter bar.
272- pub fn overdue_count(&self, today: Date) -> usize {
273- self.cards().filter(|card| card.is_overdue(today)).count()
292+ pub fn overdue_count(&self, now: OffsetDateTime) -> usize {
293+ self.cards().filter(|card| card.is_overdue(now)).count()
274294 }
275295
276296 /// The `2 blocked` chip beside it.
@@ -555,3 +575,269 @@ mod reads {
555575 )))
556576 }
557577 }
578+
579+#[cfg(test)]
580+mod deadline_is_overdue_tests {
581+ use super::*;
582+ use crate::detail::TaskDetail;
583+ use time::macros::{date, datetime};
584+
585+ /// The board's "now": mid-afternoon on the 15th.
586+ fn now() -> OffsetDateTime {
587+ datetime!(2026-09-15 15:00 UTC)
588+ }
589+
590+ fn at(day: Date, hour: u8) -> OffsetDateTime {
591+ day.with_time(time::Time::from_hms(hour, 0, 0).unwrap())
592+ .assume_utc()
593+ }
594+
595+ fn card(
596+ deadline: Option<Date>,
597+ clock_at: Option<OffsetDateTime>,
598+ done_at: Option<OffsetDateTime>,
599+ ) -> TaskCard {
600+ TaskCard {
601+ id: String::new(),
602+ task_key: String::new(),
603+ title: String::new(),
604+ column_id: String::new(),
605+ deadline,
606+ clock_at,
607+ done_at,
608+ position: 0.0,
609+ assignees: Vec::new(),
610+ comment_count: 0,
611+ blocked_by: Vec::new(),
612+ blocks: Vec::new(),
613+ subtask_total: 0,
614+ subtask_done: 0,
615+ tag: None,
616+ }
617+ }
618+
619+ fn detail(
620+ deadline: Option<Date>,
621+ clock_at: Option<OffsetDateTime>,
622+ done_at: Option<OffsetDateTime>,
623+ ) -> TaskDetail {
624+ TaskDetail {
625+ id: String::new(),
626+ task_key: String::new(),
627+ title: String::new(),
628+ description: String::new(),
629+ column: Column {
630+ id: String::new(),
631+ name: String::new(),
632+ position: 0,
633+ is_done: false,
634+ },
635+ columns: Vec::new(),
636+ tag: None,
637+ deadline,
638+ clock_at,
639+ done_at,
640+ assignees: Vec::new(),
641+ assignable: Vec::new(),
642+ blocked_by: Vec::new(),
643+ blocks: Vec::new(),
644+ comments: Vec::new(),
645+ files: Vec::new(),
646+ activity: Vec::new(),
647+ parent: None,
648+ subtasks: Vec::new(),
649+ }
650+ }
651+
652+ #[test]
653+ fn day_only_deadlines_follow_the_day() {
654+ let now = now();
655+ // Yesterday is overdue, today is not yet, tomorrow is not.
656+ assert!(deadline_is_overdue(false, Some(date!(2026 - 09 - 14)), None, now));
657+ assert!(!deadline_is_overdue(false, Some(date!(2026 - 09 - 15)), None, now));
658+ assert!(!deadline_is_overdue(false, Some(date!(2026 - 09 - 16)), None, now));
659+ // No deadline is never overdue.
660+ assert!(!deadline_is_overdue(false, None, None, now));
661+ }
662+
663+ #[test]
664+ fn the_clock_wins_and_the_instant_decides() {
665+ let now = now();
666+ // Earlier today: the instant has passed.
667+ assert!(deadline_is_overdue(
668+ false,
669+ Some(date!(2026 - 09 - 15)),
670+ Some(at(date!(2026 - 09 - 15), 9)),
671+ now
672+ ));
673+ // Later today: it has not.
674+ assert!(!deadline_is_overdue(
675+ false,
676+ Some(date!(2026 - 09 - 15)),
677+ Some(at(date!(2026 - 09 - 15), 18)),
678+ now
679+ ));
680+ // The exact instant counts as reached.
681+ assert!(deadline_is_overdue(
682+ false,
683+ Some(date!(2026 - 09 - 15)),
684+ Some(now),
685+ now
686+ ));
687+ // A past day whose clock is still ahead waits for the clock.
688+ assert!(!deadline_is_overdue(
689+ false,
690+ Some(date!(2026 - 09 - 13)),
691+ Some(at(date!(2026 - 09 - 16), 9)),
692+ now
693+ ));
694+ // A past day with a past clock is overdue.
695+ assert!(deadline_is_overdue(
696+ false,
697+ Some(date!(2026 - 09 - 13)),
698+ Some(at(date!(2026 - 09 - 13), 18)),
699+ now
700+ ));
701+ // A future day is not, whatever the clock says.
702+ assert!(!deadline_is_overdue(
703+ false,
704+ Some(date!(2026 - 09 - 16)),
705+ Some(at(date!(2026 - 09 - 16), 18)),
706+ now
707+ ));
708+ }
709+
710+ #[test]
711+ fn done_is_never_overdue() {
712+ let now = now();
713+ let done_at = Some(at(date!(2026 - 09 - 14), 12));
714+ assert!(!deadline_is_overdue(
715+ true,
716+ Some(date!(2026 - 09 - 13)),
717+ Some(at(date!(2026 - 09 - 13), 18)),
718+ now
719+ ));
720+ let finished = card(Some(date!(2026 - 09 - 13)), Some(at(date!(2026 - 09 - 13), 18)), done_at);
721+ assert!(!finished.is_overdue(now));
722+ // The card's Done arm: the chip says done, not overdue.
723+ assert_eq!(
724+ finished.deadline_parts(now).map(|parts| parts.state),
725+ Some(DeadlineState::Done)
726+ );
727+ }
728+
729+ #[test]
730+ fn card_and_detail_agree_on_the_same_facts() {
731+ let now = now();
732+ let facts = [
733+ (Some(date!(2026 - 09 - 14)), None),
734+ (Some(date!(2026 - 09 - 15)), None),
735+ (Some(date!(2026 - 09 - 15)), Some(at(date!(2026 - 09 - 15), 9))),
736+ (Some(date!(2026 - 09 - 15)), Some(at(date!(2026 - 09 - 15), 18))),
737+ (Some(date!(2026 - 09 - 13)), Some(at(date!(2026 - 09 - 13), 18))),
738+ (None, None),
739+ ];
740+ for (deadline, clock_at) in facts {
741+ assert_eq!(
742+ card(deadline, clock_at, None).is_overdue(now),
743+ detail(deadline, clock_at, None).is_overdue(now),
744+ "{deadline:?} at {clock_at:?}"
745+ );
746+ let overdue = detail(deadline, clock_at, None).is_overdue(now);
747+ assert_eq!(
748+ detail(deadline, clock_at, None)
749+ .deadline_parts(now)
750+ .map(|parts| parts.state == DeadlineState::Overdue),
751+ deadline.map(|_| overdue),
752+ "{deadline:?} at {clock_at:?}"
753+ );
754+ let card_parts = card(deadline, clock_at, None).deadline_parts(now);
755+ assert_eq!(
756+ card_parts.map(|parts| parts.state == DeadlineState::Overdue),
757+ deadline.map(|_| overdue),
758+ "{deadline:?} at {clock_at:?}"
759+ );
760+ }
761+ }
762+
763+ #[test]
764+ fn labels_stay_day_grain_but_borrow_the_boolean() {
765+ let now = now();
766+ // A passed clock prints the day, not the time; only `overdue` is new.
767+ let clocked = card(
768+ Some(date!(2026 - 09 - 15)),
769+ Some(at(date!(2026 - 09 - 15), 9)),
770+ None,
771+ );
772+ assert_eq!(clocked.deadline_label(now), "Sep 15 · overdue");
773+ // A clock still ahead prints the bare day.
774+ let waiting = card(
775+ Some(date!(2026 - 09 - 15)),
776+ Some(at(date!(2026 - 09 - 15), 18)),
777+ None,
778+ );
779+ assert_eq!(waiting.deadline_label(now), "Sep 15");
780+ // The detail agrees, and a finished task never wears the word.
781+ assert_eq!(
782+ detail(
783+ Some(date!(2026 - 09 - 15)),
784+ Some(at(date!(2026 - 09 - 15), 9)),
785+ None
786+ )
787+ .deadline_label(now),
788+ "Sep 15 · overdue"
789+ );
790+ assert_eq!(
791+ detail(
792+ Some(date!(2026 - 09 - 13)),
793+ Some(at(date!(2026 - 09 - 13), 18)),
794+ Some(at(date!(2026 - 09 - 14), 12))
795+ )
796+ .deadline_label(now),
797+ "Sep 13"
798+ );
799+ }
800+
801+ #[test]
802+ fn the_filter_chip_counts_the_same_decision() {
803+ let now = now();
804+ let view = BoardView {
805+ board: BoardMeta {
806+ id: String::new(),
807+ name: String::new(),
808+ task_prefix: String::new(),
809+ },
810+ columns: vec![ColumnView {
811+ column: Column {
812+ id: String::new(),
813+ name: String::new(),
814+ position: 0,
815+ is_done: false,
816+ },
817+ cards: vec![
818+ // Overdue: yesterday.
819+ card(Some(date!(2026 - 09 - 14)), None, None),
820+ // Overdue: the clock passed earlier today.
821+ card(
822+ Some(date!(2026 - 09 - 15)),
823+ Some(at(date!(2026 - 09 - 15), 9)),
824+ None,
825+ ),
826+ // Not overdue: the clock is still ahead.
827+ card(
828+ Some(date!(2026 - 09 - 15)),
829+ Some(at(date!(2026 - 09 - 15), 18)),
830+ None,
831+ ),
832+ // Not overdue: done.
833+ card(
834+ Some(date!(2026 - 09 - 13)),
835+ Some(at(date!(2026 - 09 - 13), 18)),
836+ Some(at(date!(2026 - 09 - 14), 12)),
837+ ),
838+ ],
839+ }],
840+ };
841+ assert_eq!(view.overdue_count(now), 2);
842+ }
843+}
crates/iz-core/src/detail.rsmodified+11 -10
@@ -8,7 +8,9 @@
88 use serde::{Deserialize, Serialize};
99 use time::{Date, OffsetDateTime, UtcOffset};
1010
11-use crate::board::{Column, DeadlineParts, DeadlineState, Person, TagChip, day_label};
11+use crate::board::{
12+ Column, DeadlineParts, DeadlineState, Person, TagChip, day_label, deadline_is_overdue,
13+};
1214
1315 /// The stored task, plus the two ids the reader needs to know it is allowed to
1416 /// see it. The description lives here rather than on
@@ -442,19 +444,18 @@ impl TaskDetail {
442444 !self.is_done() && self.blocked_by.iter().any(|edge| !edge.is_cleared())
443445 }
444446
445- pub fn is_overdue(&self, today: Date) -> bool {
446- match self.deadline {
447- Some(day) => !self.is_done() && day < today,
448- None => false,
449- }
447+ /// The same [`crate::board::deadline_is_overdue`] decision the card
448+ /// makes, so a passed clock is overdue here and there alike.
449+ pub fn is_overdue(&self, now: OffsetDateTime) -> bool {
450+ crate::board::deadline_is_overdue(self.is_done(), self.deadline, self.clock_at, now)
450451 }
451452
452453 /// The DEADLINE field's text: `Aug 21 · overdue`, `Sep 12`, `no deadline`.
453454 /// English-only — kept for non-UI callers; UI rendering should use
454455 /// [`TaskDetail::deadline_parts`] and translate.
455- pub fn deadline_label(&self, today: Date) -> String {
456+ pub fn deadline_label(&self, now: OffsetDateTime) -> String {
456457 match self.deadline {
457- Some(day) if !self.is_done() && day < today => {
458+ Some(day) if deadline_is_overdue(self.is_done(), Some(day), self.clock_at, now) => {
458459 format!("{} · overdue", day_label(day))
459460 }
460461 Some(day) => day_label(day),
@@ -465,10 +466,10 @@ impl TaskDetail {
465466 /// The same field as [`TaskDetail::deadline_label`], split into a
466467 /// language-free date string and a state the caller translates. `None`
467468 /// when there's no deadline set.
468- pub fn deadline_parts(&self, today: Date) -> Option<DeadlineParts> {
469+ pub fn deadline_parts(&self, now: OffsetDateTime) -> Option<DeadlineParts> {
469470 self.deadline.map(|day| DeadlineParts {
470471 date: day_label(day),
471- state: if !self.is_done() && day < today {
472+ state: if deadline_is_overdue(self.is_done(), Some(day), self.clock_at, now) {
472473 DeadlineState::Overdue
473474 } else {
474475 DeadlineState::OnTime
crates/iz-core/tests/store.rsmodified+4 -4
@@ -1342,10 +1342,10 @@ async fn a_card_carries_its_assignees_comments_and_dependency_keys() {
13421342 assert_eq!(waiting.comment_count, 0);
13431343 assert!(waiting.assignees.is_empty());
13441344
1345- let today = date!(2026 - 08 - 26);
1346- assert_eq!(card.deadline_label(today), "Aug 21 · overdue");
1347- assert_eq!(waiting.deadline_label(today), "Oct 06");
1348- assert_eq!(board.overdue_count(today), 1);
1345+ let now = date!(2026 - 08 - 26).midnight().assume_utc();
1346+ assert_eq!(card.deadline_label(now), "Aug 21 · overdue");
1347+ assert_eq!(waiting.deadline_label(now), "Oct 06");
1348+ assert_eq!(board.overdue_count(now), 1);
13491349 assert_eq!(board.blocked_count(), 1);
13501350 }
13511351
crates/iz-web/src/board.rsmodified+14 -15
@@ -8,7 +8,7 @@
88
99 use iz_core::board::{DeadlineState, Moved, TaskCard, day_label};
1010 use iz_core::store::{NewTask, User};
11-use time::{Date, OffsetDateTime};
11+use time::OffsetDateTime;
1212 use topcoat::Result;
1313 use topcoat::context::Cx;
1414 use topcoat::router::content::Form;
@@ -350,6 +350,7 @@ fn sort_column_cards(cards: &mut [TaskCard], sort: &str) {
350350 /// The whole column list.
351351 async fn board_columns<'a>(
352352 cx: &'a Cx,
353+ now: OffsetDateTime,
353354 sort: String,
354355 tag_filter: Option<String>,
355356 assigned: Option<String>,
@@ -387,7 +388,6 @@ async fn board_columns<'a>(
387388 column.column.name = crate::i18n::column_name(lang, &column.column.name);
388389 sort_column_cards(&mut column.cards, &sort);
389390 }
390- let today = OffsetDateTime::now_utc().date();
391391 let may_write = user.role.can_write_tasks();
392392 let zone = iz_core::detail::parse_zone(&user.timezone);
393393
@@ -402,7 +402,7 @@ async fn board_columns<'a>(
402402 render_column(
403403 cx,
404404 column,
405- today,
405+ now,
406406 zone,
407407 may_write,
408408 &all_columns,
@@ -424,7 +424,7 @@ async fn board_columns<'a>(
424424 async fn render_column<'a>(
425425 cx: &'a Cx,
426426 column: iz_core::board::ColumnView,
427- today: Date,
427+ now: OffsetDateTime,
428428 zone: time::UtcOffset,
429429 may_write: bool,
430430 all_columns: &[(String, String)],
@@ -442,7 +442,7 @@ async fn render_column<'a>(
442442 render_card(
443443 cx,
444444 card,
445- today,
445+ now,
446446 is_done_column,
447447 zone,
448448 &column_id,
@@ -478,7 +478,7 @@ async fn render_column<'a>(
478478 async fn render_card<'a>(
479479 cx: &'a Cx,
480480 card: TaskCard,
481- today: Date,
481+ now: OffsetDateTime,
482482 done_column: bool,
483483 zone: time::UtcOffset,
484484 column_id: &str,
@@ -489,11 +489,9 @@ async fn render_card<'a>(
489489 ) -> Result<impl View + 'a> {
490490 let blocks = card.blocks.join(", ");
491491 let blocked_by = card.blocked_by.join(", ");
492- let overdue = card.is_overdue(today);
493- let deadline_parts = card.deadline_parts(today);
494- // A clock is the meeting's exact instant, read in the viewer's own zone;
495- // when it exists it is the whole chip — the day-grain deadline keeps its
496- // own state machinery out of the way rather than standing next to it.
492+ let overdue = card.is_overdue(now);
493+ let deadline_parts = card.deadline_parts(now);
494+ // Overdue is `is_overdue`; the clock only changes the label text.
497495 let clock = card.clock_at.map(|at| {
498496 let at = at.to_offset(zone);
499497 format!(
@@ -506,6 +504,7 @@ async fn render_card<'a>(
506504 let has_clock = clock.is_some();
507505 let dated = deadline_parts.is_some() || has_clock;
508506 let deadline = match clock {
507+ Some(label) if overdue => format!("{label} · {}", t(lang, Key::Overdue)),
509508 Some(label) => label,
510509 None => match deadline_parts {
511510 Some(parts) => match parts.state {
@@ -548,7 +547,7 @@ async fn render_card<'a>(
548547 <div class="card-foot">
549548 // Overdue is a comparison against today, so a tab left open
550549 // over midnight is wrong until something re-renders it.
551- <span data-tick=(dated.then_some("")) class=(class!("card-deadline", "card-deadline-overdue" if overdue && !has_clock, "card-deadline-none" if !dated))>
550+ <span data-tick=(dated.then_some("")) class=(class!("card-deadline", "card-deadline-overdue" if overdue, "card-deadline-none" if !dated))>
552551 (deadline)
553552 </span>
554553 if let Some(tag) = &card.tag {
@@ -800,8 +799,8 @@ pub async fn board_page<'a>(cx: &'a Cx, user: &'a User) -> Result<impl View + 'a
800799 }
801800 view_data.tagged(tag_filter.as_deref());
802801 view_data.assigned(assigned_filter.as_deref());
803- let today = OffsetDateTime::now_utc().date();
804- let overdue = view_data.overdue_count(today);
802+ let now = OffsetDateTime::now_utc();
803+ let overdue = view_data.overdue_count(now);
805804 let blocked = view_data.blocked_count();
806805 let may_write = user.role.can_write_tasks();
807806 let all_columns: Vec<(String, String)> = view_data
@@ -951,7 +950,7 @@ pub async fn board_page<'a>(cx: &'a Cx, user: &'a User) -> Result<impl View + 'a
951950 <div class="scaffold-note"><p>(t(lang, Key::NoMatches))</p></div>
952951 } else {
953952 <div class="board-columns">
954- (topcoat::view::Child::new(board_columns(cx, sort.clone(), tag_filter.clone(), assigned_filter.clone(), search.clone(), default_tag_id).await?))
953+ (topcoat::view::Child::new(board_columns(cx, now, sort.clone(), tag_filter.clone(), assigned_filter.clone(), search.clone(), default_tag_id).await?))
955954 </div>
956955 }
957956 </main>
crates/iz-web/src/detail.rsmodified+5 -5
@@ -1370,14 +1370,14 @@ async fn description_control<'a>(
13701370 async fn deadline_control<'a>(
13711371 cx: &'a Cx,
13721372 task: &'a TaskDetail,
1373- today: Date,
1373+ now: time::OffsetDateTime,
13741374 zone: UtcOffset,
13751375 may_write: bool,
13761376 lang: Lang,
13771377 ) -> Result<impl View + 'a> {
1378- let overdue = task.is_overdue(today);
1378+ let overdue = task.is_overdue(now);
13791379 let local = task.clock_at.map(|at| at.to_offset(zone));
1380- let label = match (&local, task.deadline_parts(today)) {
1380+ let label = match (&local, task.deadline_parts(now)) {
13811381 (Some(at), Some(parts)) if parts.state == DeadlineState::Overdue => {
13821382 format!(
13831383 "{} {:02}:{:02} · {}",
@@ -2096,7 +2096,7 @@ pub async fn task_modal<'a>(
20962096 let DetailSnapshot {
20972097 detail,
20982098 me,
2099- today,
2099+ today: _,
21002100 zone,
21012101 linkable,
21022102 adoptable,
@@ -2256,7 +2256,7 @@ pub async fn task_modal<'a>(
22562256 </div>
22572257 <div class="detail-field">
22582258 <span class="detail-label">(t(lang, Key::Deadline))</span>
2259- (topcoat::view::Child::new(deadline_control(cx, &detail, today, zone, may_write, lang).await?))
2259+ (topcoat::view::Child::new(deadline_control(cx, &detail, time::OffsetDateTime::now_utc(), zone, may_write, lang).await?))
22602260 </div>
22612261 <div class="detail-field detail-field-people">
22622262 <span class="detail-label">(format!("{} — {}", t(lang, Key::Assignees), detail.assignees.len()))</span>
crates/iz-web/tests/http.rsmodified+104 -0
@@ -9132,6 +9132,110 @@ async fn a_card_wears_the_clock_chip_in_the_viewers_zone_instead_of_the_deadline
91329132 );
91339133 }
91349134
9135+/// A clock that has passed makes the card overdue the same way the detail
9136+/// already is: the chip carries ` · overdue` and the overdue class, the
9137+/// filter count counts it, and the detail field keeps its own
9138+/// `day time · overdue` shape. A future clock on the same board stays clean.
9139+#[tokio::test]
9140+async fn a_past_clock_reads_overdue_on_the_card_like_the_detail() {
9141+ let app = App::open().await;
9142+ let admin_cookie = admin(&app).await;
9143+
9144+ // The viewer is pinned to UTC, so the typed 18:00 is the stored instant.
9145+ app.store
9146+ .sync_member("im-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC")
9147+ .await
9148+ .unwrap();
9149+
9150+ let column = first_column(&app).await;
9151+ let yesterday = time::OffsetDateTime::now_utc() - time::Duration::days(1);
9152+ let ymd = format!(
9153+ "{:04}-{:02}-{:02}",
9154+ yesterday.year(),
9155+ yesterday.month() as u8,
9156+ yesterday.day()
9157+ );
9158+ let answer = app
9159+ .post(
9160+ "/api/create_task",
9161+ Some(&admin_cookie),
9162+ &[
9163+ ("title", "Standup"),
9164+ ("column_id", &column),
9165+ ("deadline", &ymd),
9166+ ("clock_hour", "18"),
9167+ ("clock_minute", "00"),
9168+ ],
9169+ )
9170+ .await;
9171+ assert!(
9172+ !answer
9173+ .location
9174+ .as_deref()
9175+ .unwrap_or_default()
9176+ .contains("refusal="),
9177+ "{:?}",
9178+ answer.location
9179+ );
9180+
9181+ // A same-request control: a clock still ahead of now never reads overdue.
9182+ let later = app
9183+ .post(
9184+ "/api/create_task",
9185+ Some(&admin_cookie),
9186+ &[
9187+ ("title", "Kickoff later"),
9188+ ("column_id", &column),
9189+ ("deadline", "2027-09-02"),
9190+ ("clock_hour", "18"),
9191+ ("clock_minute", "00"),
9192+ ],
9193+ )
9194+ .await;
9195+ assert!(
9196+ !later
9197+ .location
9198+ .as_deref()
9199+ .unwrap_or_default()
9200+ .contains("refusal="),
9201+ "{:?}",
9202+ later.location
9203+ );
9204+
9205+ let workspace_id = app.workspace_id().await;
9206+ let board = iz_core::board::load(app.store.as_ref(), &workspace_id)
9207+ .await
9208+ .unwrap()
9209+ .unwrap();
9210+ let task = board
9211+ .cards()
9212+ .find(|card| card.title == "Standup")
9213+ .expect("the overdue task is not on the board")
9214+ .id
9215+ .clone();
9216+
9217+ let day = iz_core::board::day_label(yesterday.date());
9218+ let page = app.get("/", Some(&admin_cookie)).await;
9219+ let html = String::from_utf8_lossy(&page.bytes);
9220+ assert!(
9221+ html.contains(&format!(
9222+ r#"data-tick="" class="card-deadline card-deadline-overdue">{day} · 18:00 · overdue<"#
9223+ )),
9224+ "{html}"
9225+ );
9226+ assert!(
9227+ html.contains(r#"data-tick="" class="card-deadline">Sep 02 · 18:00<"#),
9228+ "the future clock picked up an overdue mark: {html}"
9229+ );
9230+
9231+ // The detail keeps its own shape: `day time · overdue`, no middle dot
9232+ // between day and time.
9233+ let page = app.get(&format!("/?task={task}"), Some(&admin_cookie)).await;
9234+ let html = String::from_utf8_lossy(&page.bytes);
9235+ assert!(html.contains("detail-overdue"), "{html}");
9236+ assert!(html.contains(&format!("{day} 18:00 · overdue")), "{html}");
9237+}
9238+
91359239 #[tokio::test]
91369240 async fn a_time_set_on_an_existing_day_writes_both_columns() {
91379241 let app = App::open().await;