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 {
178 !self.is_done() && !self.blocked_by.is_empty()178 !self.is_done() && !self.blocked_by.is_empty()
179 }179 }
180 180
181- /// Past its deadline and not finished. A deadline of today is not overdue.181+ /// Past its deadline and not finished — the shared
182- pub fn is_overdue(&self, today: Date) -> bool {182+ /// [`deadline_is_overdue`] decision, so a passed clock counts here even
183- match self.deadline {183+ /// though the card shows the clock rather than the day.
184- Some(day) => !self.is_done() && day < today,184+ pub fn is_overdue(&self, now: OffsetDateTime) -> bool {
185- None => false,185+ deadline_is_overdue(self.is_done(), self.deadline, self.clock_at, now)
186- }
187 }186 }
188 187
189 pub fn is_assigned_to(&self, user_id: &str) -> bool {188 pub fn is_assigned_to(&self, user_id: &str) -> bool {
@@ -194,12 +193,14 @@ impl TaskCard {
194 /// `Aug 21 · overdue`, `done Aug 14` or `no deadline`. English-only —193 /// `Aug 21 · overdue`, `done Aug 14` or `no deadline`. English-only —
195 /// kept for callers (mail, tests) that want the baked sentence; UI194 /// kept for callers (mail, tests) that want the baked sentence; UI
196 /// rendering should use [`TaskCard::deadline_parts`] and translate.195 /// 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 {
198 if let Some(done) = self.done_at {197 if let Some(done) = self.done_at {
199 return format!("done {}", day_label(done.date()));198 return format!("done {}", day_label(done.date()));
200 }199 }
201 match self.deadline {200 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+ }
203 Some(day) => day_label(day),204 Some(day) => day_label(day),
204 None => "no deadline".to_string(),205 None => "no deadline".to_string(),
205 }206 }
@@ -208,7 +209,7 @@ impl TaskCard {
208 /// The same chip as [`TaskCard::deadline_label`], split into a209 /// The same chip as [`TaskCard::deadline_label`], split into a
209 /// language-free date string and a state the caller translates.210 /// language-free date string and a state the caller translates.
210 /// `None` when there's nothing to show (no deadline, not done).211 /// `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> {
212 if let Some(done) = self.done_at {213 if let Some(done) = self.done_at {
213 return Some(DeadlineParts {214 return Some(DeadlineParts {
214 date: day_label(done.date()),215 date: day_label(done.date()),
@@ -217,7 +218,7 @@ impl TaskCard {
217 }218 }
218 self.deadline.map(|day| DeadlineParts {219 self.deadline.map(|day| DeadlineParts {
219 date: day_label(day),220 date: day_label(day),
220- state: if day < today {221+ state: if deadline_is_overdue(false, Some(day), self.clock_at, now) {
221 DeadlineState::Overdue222 DeadlineState::Overdue
222 } else {223 } else {
223 DeadlineState::OnTime224 DeadlineState::OnTime
@@ -241,6 +242,25 @@ pub enum DeadlineState {
241 Done,242 Done,
242 }243 }
243 244
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+
244 /// A column with its cards already in it.264 /// A column with its cards already in it.
245 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]265 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
246 pub struct ColumnView {266 pub struct ColumnView {
@@ -269,8 +289,8 @@ impl BoardView {
269 }289 }
270 290
271 /// The `1 overdue` chip in the filter bar.291 /// The `1 overdue` chip in the filter bar.
272- pub fn overdue_count(&self, today: Date) -> usize {292+ pub fn overdue_count(&self, now: OffsetDateTime) -> usize {
273- self.cards().filter(|card| card.is_overdue(today)).count()293+ self.cards().filter(|card| card.is_overdue(now)).count()
274 }294 }
275 295
276 /// The `2 blocked` chip beside it.296 /// The `2 blocked` chip beside it.
@@ -555,3 +575,269 @@ mod reads {
555 )))575 )))
556 }576 }
557 }577 }
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 @@
8 use serde::{Deserialize, Serialize};8 use serde::{Deserialize, Serialize};
9 use time::{Date, OffsetDateTime, UtcOffset};9 use time::{Date, OffsetDateTime, UtcOffset};
10 10
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+};
12 14
13 /// The stored task, plus the two ids the reader needs to know it is allowed to15 /// The stored task, plus the two ids the reader needs to know it is allowed to
14 /// see it. The description lives here rather than on16 /// see it. The description lives here rather than on
@@ -442,19 +444,18 @@ impl TaskDetail {
442 !self.is_done() && self.blocked_by.iter().any(|edge| !edge.is_cleared())444 !self.is_done() && self.blocked_by.iter().any(|edge| !edge.is_cleared())
443 }445 }
444 446
445- pub fn is_overdue(&self, today: Date) -> bool {447+ /// The same [`crate::board::deadline_is_overdue`] decision the card
446- match self.deadline {448+ /// makes, so a passed clock is overdue here and there alike.
447- Some(day) => !self.is_done() && day < today,449+ pub fn is_overdue(&self, now: OffsetDateTime) -> bool {
448- None => false,450+ crate::board::deadline_is_overdue(self.is_done(), self.deadline, self.clock_at, now)
449- }
450 }451 }
451 452
452 /// The DEADLINE field's text: `Aug 21 · overdue`, `Sep 12`, `no deadline`.453 /// The DEADLINE field's text: `Aug 21 · overdue`, `Sep 12`, `no deadline`.
453 /// English-only — kept for non-UI callers; UI rendering should use454 /// English-only — kept for non-UI callers; UI rendering should use
454 /// [`TaskDetail::deadline_parts`] and translate.455 /// [`TaskDetail::deadline_parts`] and translate.
455- pub fn deadline_label(&self, today: Date) -> String {456+ pub fn deadline_label(&self, now: OffsetDateTime) -> String {
456 match self.deadline {457 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) => {
458 format!("{} · overdue", day_label(day))459 format!("{} · overdue", day_label(day))
459 }460 }
460 Some(day) => day_label(day),461 Some(day) => day_label(day),
@@ -465,10 +466,10 @@ impl TaskDetail {
465 /// The same field as [`TaskDetail::deadline_label`], split into a466 /// The same field as [`TaskDetail::deadline_label`], split into a
466 /// language-free date string and a state the caller translates. `None`467 /// language-free date string and a state the caller translates. `None`
467 /// when there's no deadline set.468 /// 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> {
469 self.deadline.map(|day| DeadlineParts {470 self.deadline.map(|day| DeadlineParts {
470 date: day_label(day),471 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) {
472 DeadlineState::Overdue473 DeadlineState::Overdue
473 } else {474 } else {
474 DeadlineState::OnTime475 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() {
1342 assert_eq!(waiting.comment_count, 0);1342 assert_eq!(waiting.comment_count, 0);
1343 assert!(waiting.assignees.is_empty());1343 assert!(waiting.assignees.is_empty());
1344 1344
1345- let today = date!(2026 - 08 - 26);1345+ let now = date!(2026 - 08 - 26).midnight().assume_utc();
1346- assert_eq!(card.deadline_label(today), "Aug 21 · overdue");1346+ assert_eq!(card.deadline_label(now), "Aug 21 · overdue");
1347- assert_eq!(waiting.deadline_label(today), "Oct 06");1347+ assert_eq!(waiting.deadline_label(now), "Oct 06");
1348- assert_eq!(board.overdue_count(today), 1);1348+ assert_eq!(board.overdue_count(now), 1);
1349 assert_eq!(board.blocked_count(), 1);1349 assert_eq!(board.blocked_count(), 1);
1350 }1350 }
1351 1351
crates/iz-web/src/board.rsmodified+14 -15
@@ -8,7 +8,7 @@
8 8
9 use iz_core::board::{DeadlineState, Moved, TaskCard, day_label};9 use iz_core::board::{DeadlineState, Moved, TaskCard, day_label};
10 use iz_core::store::{NewTask, User};10 use iz_core::store::{NewTask, User};
11-use time::{Date, OffsetDateTime};11+use time::OffsetDateTime;
12 use topcoat::Result;12 use topcoat::Result;
13 use topcoat::context::Cx;13 use topcoat::context::Cx;
14 use topcoat::router::content::Form;14 use topcoat::router::content::Form;
@@ -350,6 +350,7 @@ fn sort_column_cards(cards: &mut [TaskCard], sort: &str) {
350 /// The whole column list.350 /// The whole column list.
351 async fn board_columns<'a>(351 async fn board_columns<'a>(
352 cx: &'a Cx,352 cx: &'a Cx,
353+ now: OffsetDateTime,
353 sort: String,354 sort: String,
354 tag_filter: Option<String>,355 tag_filter: Option<String>,
355 assigned: Option<String>,356 assigned: Option<String>,
@@ -387,7 +388,6 @@ async fn board_columns<'a>(
387 column.column.name = crate::i18n::column_name(lang, &column.column.name);388 column.column.name = crate::i18n::column_name(lang, &column.column.name);
388 sort_column_cards(&mut column.cards, &sort);389 sort_column_cards(&mut column.cards, &sort);
389 }390 }
390- let today = OffsetDateTime::now_utc().date();
391 let may_write = user.role.can_write_tasks();391 let may_write = user.role.can_write_tasks();
392 let zone = iz_core::detail::parse_zone(&user.timezone);392 let zone = iz_core::detail::parse_zone(&user.timezone);
393 393
@@ -402,7 +402,7 @@ async fn board_columns<'a>(
402 render_column(402 render_column(
403 cx,403 cx,
404 column,404 column,
405- today,405+ now,
406 zone,406 zone,
407 may_write,407 may_write,
408 &all_columns,408 &all_columns,
@@ -424,7 +424,7 @@ async fn board_columns<'a>(
424 async fn render_column<'a>(424 async fn render_column<'a>(
425 cx: &'a Cx,425 cx: &'a Cx,
426 column: iz_core::board::ColumnView,426 column: iz_core::board::ColumnView,
427- today: Date,427+ now: OffsetDateTime,
428 zone: time::UtcOffset,428 zone: time::UtcOffset,
429 may_write: bool,429 may_write: bool,
430 all_columns: &[(String, String)],430 all_columns: &[(String, String)],
@@ -442,7 +442,7 @@ async fn render_column<'a>(
442 render_card(442 render_card(
443 cx,443 cx,
444 card,444 card,
445- today,445+ now,
446 is_done_column,446 is_done_column,
447 zone,447 zone,
448 &column_id,448 &column_id,
@@ -478,7 +478,7 @@ async fn render_column<'a>(
478 async fn render_card<'a>(478 async fn render_card<'a>(
479 cx: &'a Cx,479 cx: &'a Cx,
480 card: TaskCard,480 card: TaskCard,
481- today: Date,481+ now: OffsetDateTime,
482 done_column: bool,482 done_column: bool,
483 zone: time::UtcOffset,483 zone: time::UtcOffset,
484 column_id: &str,484 column_id: &str,
@@ -489,11 +489,9 @@ async fn render_card<'a>(
489 ) -> Result<impl View + 'a> {489 ) -> Result<impl View + 'a> {
490 let blocks = card.blocks.join(", ");490 let blocks = card.blocks.join(", ");
491 let blocked_by = card.blocked_by.join(", ");491 let blocked_by = card.blocked_by.join(", ");
492- let overdue = card.is_overdue(today);492+ let overdue = card.is_overdue(now);
493- let deadline_parts = card.deadline_parts(today);493+ let deadline_parts = card.deadline_parts(now);
494- // A clock is the meeting's exact instant, read in the viewer's own zone;494+ // Overdue is `is_overdue`; the clock only changes the label text.
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.
497 let clock = card.clock_at.map(|at| {495 let clock = card.clock_at.map(|at| {
498 let at = at.to_offset(zone);496 let at = at.to_offset(zone);
499 format!(497 format!(
@@ -506,6 +504,7 @@ async fn render_card<'a>(
506 let has_clock = clock.is_some();504 let has_clock = clock.is_some();
507 let dated = deadline_parts.is_some() || has_clock;505 let dated = deadline_parts.is_some() || has_clock;
508 let deadline = match clock {506 let deadline = match clock {
507+ Some(label) if overdue => format!("{label} · {}", t(lang, Key::Overdue)),
509 Some(label) => label,508 Some(label) => label,
510 None => match deadline_parts {509 None => match deadline_parts {
511 Some(parts) => match parts.state {510 Some(parts) => match parts.state {
@@ -548,7 +547,7 @@ async fn render_card<'a>(
548 <div class="card-foot">547 <div class="card-foot">
549 // Overdue is a comparison against today, so a tab left open548 // Overdue is a comparison against today, so a tab left open
550 // over midnight is wrong until something re-renders it.549 // 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))>
552 (deadline)551 (deadline)
553 </span>552 </span>
554 if let Some(tag) = &card.tag {553 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
800 }799 }
801 view_data.tagged(tag_filter.as_deref());800 view_data.tagged(tag_filter.as_deref());
802 view_data.assigned(assigned_filter.as_deref());801 view_data.assigned(assigned_filter.as_deref());
803- let today = OffsetDateTime::now_utc().date();802+ let now = OffsetDateTime::now_utc();
804- let overdue = view_data.overdue_count(today);803+ let overdue = view_data.overdue_count(now);
805 let blocked = view_data.blocked_count();804 let blocked = view_data.blocked_count();
806 let may_write = user.role.can_write_tasks();805 let may_write = user.role.can_write_tasks();
807 let all_columns: Vec<(String, String)> = view_data806 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
951 <div class="scaffold-note"><p>(t(lang, Key::NoMatches))</p></div>950 <div class="scaffold-note"><p>(t(lang, Key::NoMatches))</p></div>
952 } else {951 } else {
953 <div class="board-columns">952 <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?))
955 </div>954 </div>
956 }955 }
957 </main>956 </main>
crates/iz-web/src/detail.rsmodified+5 -5
@@ -1370,14 +1370,14 @@ async fn description_control<'a>(
1370 async fn deadline_control<'a>(1370 async fn deadline_control<'a>(
1371 cx: &'a Cx,1371 cx: &'a Cx,
1372 task: &'a TaskDetail,1372 task: &'a TaskDetail,
1373- today: Date,1373+ now: time::OffsetDateTime,
1374 zone: UtcOffset,1374 zone: UtcOffset,
1375 may_write: bool,1375 may_write: bool,
1376 lang: Lang,1376 lang: Lang,
1377 ) -> Result<impl View + 'a> {1377 ) -> Result<impl View + 'a> {
1378- let overdue = task.is_overdue(today);1378+ let overdue = task.is_overdue(now);
1379 let local = task.clock_at.map(|at| at.to_offset(zone));1379 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)) {
1381 (Some(at), Some(parts)) if parts.state == DeadlineState::Overdue => {1381 (Some(at), Some(parts)) if parts.state == DeadlineState::Overdue => {
1382 format!(1382 format!(
1383 "{} {:02}:{:02} · {}",1383 "{} {:02}:{:02} · {}",
@@ -2096,7 +2096,7 @@ pub async fn task_modal<'a>(
2096 let DetailSnapshot {2096 let DetailSnapshot {
2097 detail,2097 detail,
2098 me,2098 me,
2099- today,2099+ today: _,
2100 zone,2100 zone,
2101 linkable,2101 linkable,
2102 adoptable,2102 adoptable,
@@ -2256,7 +2256,7 @@ pub async fn task_modal<'a>(
2256 </div>2256 </div>
2257 <div class="detail-field">2257 <div class="detail-field">
2258 <span class="detail-label">(t(lang, Key::Deadline))</span>2258 <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?))
2260 </div>2260 </div>
2261 <div class="detail-field detail-field-people">2261 <div class="detail-field detail-field-people">
2262 <span class="detail-label">(format!("{} — {}", t(lang, Key::Assignees), detail.assignees.len()))</span>2262 <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
9132 );9132 );
9133 }9133 }
9134 9134
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+
9135 #[tokio::test]9239 #[tokio::test]
9136 async fn a_time_set_on_an_existing_day_writes_both_columns() {9240 async fn a_time_set_on_an_existing_day_writes_both_columns() {
9137 let app = App::open().await;9241 let app = App::open().await;