Urgent.News

What's breaking now, across thousands of outlets.

Tech

A Query Window Is Not a Calendar Day

Software often uses broad time windows for good reasons. A dashboard may need recent history, work that is actionable now, and the next scheduled item. Fetching all of that in one bounded query can be efficient and easy to reason about. The trouble begins when the retrieval window quietly becomes the business definition of “today.” This is a small distinction with a very visible failure mode:…

Software developers often utilize broad time windows in their code for efficiency and clarity. A dashboard may require recent history, current actionable work, and the upcoming item, fetching all this data in a single query can be both efficient and easy to manage. However, a subtle issue arises when this retrieval window is unintentionally equated with the business meaning of "today."

This seemingly minor distinction can lead to significant failures, such as outdated missed items being displayed under the wrong day. The problem lies in the fact that the retrieval and meaning are two distinct tasks. For instance, a "Today" screen that displays items from several hours in the past to the next day needs both a look-back and a look-ahead.

This range of dates is a retrieval concern, answering the question of which records might be relevant, but it does not define which record belongs to the user’s current calendar day. This distinction is critical because it prevents errors like misclassifying a missed item from yesterday as today’s item. To avoid such issues, it is essential to define "today" in the relevant time zone, as server time is rarely the correct authority for a human-facing day.

UTC is ideal for storing instants and comparing elapsed time but is not a user’s calendar. The recommended approach is to read the current instant from an injected clock, convert it once into the user’s time zone, derive a local date from that value, and use it to classify calendar-bound states. This method ensures that every decision is anchored to the same instant, including scenarios where execution crosses midnight.

Additionally, it is crucial to explicitly define the relevant time zone, which could be a person, site, account, or workflow. The decision should be made at the domain level rather than relying on infrastructure defaults. A tempting but incorrect fix is to discard every record whose local date is not today. This approach fails if an actionable window crosses midnight.

For example, a task that opened before midnight and remains valid until shortly afterwards would be hidden at the exact moment it still needs attention. This illustrates the importance of explicit domain rules over blanket filtering. Proper handling of intention requires making the difference between actionable and non-actionable items clear.

Time bugs are not limited to sorting and filtering; labels can also encode false claims. Phrases like "Later today" or "Between 08:00 and 09:00" can be misleading if viewed outside of the relevant date. Explicitly stating the time frame in a user-friendly manner helps avoid ambiguity. Testing is crucial to catch these issues. A single test at noon is insufficient; instead, the test should move a controllable clock through the state transition, verifying correctness before, during, and after midnight.

The test should also consider the persistence provider, generated occurrences, and query translation, as they all contribute to the behavior. Testing in this manner ensures the system behaves as expected throughout the day. Implementing explicit local-date classification incurs a few trade-offs, such as more branches in the code, a time-zone conversion at the application boundary, and boundary-focused tests.

However, these costs are justified by the predictability and correctness of the system. Retrieval can remain broad to ensure performance and completeness, while classification becomes precise. User-facing language should reflect the same model to maintain consistency. The broader implication is to always ask two key questions when encountering time ranges in code: Is this range finding candidates or defining business membership?

Whose calendar determines the meaning of terms like today, tomorrow, and missed? Separate these concerns to prevent implementation conveniences from becoming accidental policies. A practical checklist for building a day-oriented view includes storing and comparing instants consistently, identifying the domain-owned time zone, deriving the local date once per operation, keeping retrieval windows separate from classification rules, preserving intentionally actionable cross-midnight windows, making off-day wording explicit, and testing before, after, and during midnight. Even if the code queries eighteen or thirty hours, users should always experience a calendar day.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Qwen3-Coder 30B on a Surface Laptop Ultra: run it on RTX Spark with Ollama

My Surface Laptop Ultra decodes short code replies from qwen3-coder:30b at 90.9 tokens a second , twice the 44.7 that Microsoft's Lenovo Yoga 9n review measured for Qwen3.8-27B on the same chip.

  • Qwen3-coder:30B model runs on Surface Laptop Ultra with RTX Spark GPU
  • Surface Laptop Ultra achieves 90.9 tokens per second decoding speed
  • Ollama enables local Qwen3-coder model operation without Docker or vLLM

Adding a Mobile‑First TabBar to the Albaida‑Tickets Dashboard (React + Next.js)

Adding a Mobile‑First TabBar to the Albaida‑Tickets Dashboard (React + Next.js) TL;DR: I added a client‑side TabBar.tsx component to make the Albaida‑Tickets admin UI usable on phones, wiring it to…

  • Client-side TabBar component added to Albaida-Tickets dashboard
  • TabBar component uses next/link, useRouter, and clsx for navigation
  • Fixed bottom navigation bar displayed on mobile views

More from Monday 26 October →