<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abdul Hannan Usama</title>
    <description>The latest articles on DEV Community by Abdul Hannan Usama (@abdul_hannanusama_0aee69).</description>
    <link>https://dev.to/abdul_hannanusama_0aee69</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4089834%2F99c42492-a8b8-40b7-9a46-45ff894716b1.png</url>
      <title>DEV Community: Abdul Hannan Usama</title>
      <link>https://dev.to/abdul_hannanusama_0aee69</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abdul_hannanusama_0aee69"/>
    <language>en</language>
    <item>
      <title>Why “Is the Bank Open Today?” Is Surprisingly Difficult to Answer with Code</title>
      <dc:creator>Abdul Hannan Usama</dc:creator>
      <pubDate>Thu, 03 Sep 2026 21:54:24 +0000</pubDate>
      <link>https://dev.to/abdul_hannanusama_0aee69/why-is-the-bank-open-today-is-surprisingly-difficult-to-answer-with-code-1c8e</link>
      <guid>https://dev.to/abdul_hannanusama_0aee69/why-is-the-bank-open-today-is-surprisingly-difficult-to-answer-with-code-1c8e</guid>
      <description>&lt;p&gt;Why “Is the Bank Open Today?” Is Surprisingly Difficult to Answer with Code&lt;br&gt;
A question like:&lt;br&gt;
“Is my bank open today?”&lt;br&gt;
sounds incredibly simple.&lt;br&gt;
A developer might initially think the logic is something like:&lt;br&gt;
if (day === "Saturday" || day === "Sunday") {&lt;br&gt;
  return "Closed";&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;return "Open";&lt;br&gt;
Unfortunately, real-world business hours don't work that way.&lt;br&gt;
Once you start building software around banks, government offices, healthcare providers, shipping companies, or any other service that operates on a calendar, you quickly discover that time is one of the messiest forms of data to model.&lt;br&gt;
A bank can be closed because it's Sunday.&lt;br&gt;
Or Saturday.&lt;br&gt;
Or a federal holiday.&lt;br&gt;
Or because the holiday was observed on a different weekday.&lt;br&gt;
Or because that particular branch has different hours.&lt;br&gt;
Or because the branch is open but drive-through services have different hours.&lt;br&gt;
This is one of those seemingly simple problems that becomes interesting the moment you try to automate it.&lt;br&gt;
That's the idea behind &lt;a href="https://banksopentoday.com/usa" rel="noopener noreferrer"&gt;BanksOpenToday.com&lt;/a&gt;⁠� — turning a question people commonly ask into something that can be answered through structured information rather than guesswork.&lt;br&gt;
The first mistake: treating a calendar as a list of weekdays&lt;br&gt;
Let's start with the obvious implementation.&lt;br&gt;
const day = new Date().getDay();&lt;/p&gt;

&lt;p&gt;const weekend = day === 0 || day === 6;&lt;/p&gt;

&lt;p&gt;console.log(weekend ? "Closed" : "Potentially open");&lt;br&gt;
This works surprisingly well as a first approximation.&lt;br&gt;
But notice the word potentially.&lt;br&gt;
A weekday doesn't automatically mean a bank is open.&lt;br&gt;
In the United States, the Federal Reserve's holiday schedule includes dates such as Independence Day, Labor Day, Thanksgiving and Christmas. �&lt;br&gt;
Federal Reserve&lt;br&gt;
That means our simple algorithm needs another dimension:&lt;br&gt;
Is it a weekend?&lt;br&gt;
        ↓&lt;br&gt;
Is it a holiday?&lt;br&gt;
        ↓&lt;br&gt;
Is the holiday observed today?&lt;br&gt;
        ↓&lt;br&gt;
Does the institution operate today?&lt;br&gt;
        ↓&lt;br&gt;
What are the branch-specific hours?&lt;br&gt;
Suddenly, "is today Tuesday?" isn't enough.&lt;br&gt;
The real problem is temporal data&lt;br&gt;
This is what makes seemingly simple services like a bank-hours checker interesting from a software engineering perspective.&lt;br&gt;
You're not really answering:&lt;br&gt;
Is today Monday?&lt;br&gt;
You're answering something closer to:&lt;br&gt;
Given a location, institution, date, timezone and holiday calendar, should this service be considered operational at this particular moment?&lt;br&gt;
That's a very different problem.&lt;br&gt;
A useful mental model is:&lt;br&gt;
Business Status =&lt;br&gt;
    Calendar&lt;br&gt;
    + Holiday Rules&lt;br&gt;
    + Observed Dates&lt;br&gt;
    + Location&lt;br&gt;
    + Operating Hours&lt;br&gt;
    + Time Zone&lt;br&gt;
    + Exceptions&lt;br&gt;
Each component can introduce edge cases.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Weekends
The easiest case.
function isWeekend(date) {
const day = date.getDay();
return day === 0 || day === 6;
}
But even here, we shouldn't automatically assume that every financial service follows exactly the same schedule.&lt;/li&gt;
&lt;li&gt;Holidays
This is where things get more interesting.
Instead of hardcoding:
if (date === "2026-09-07") {
return "Closed";
}
a better system represents holidays as structured data.
For example:
const holidays = [
{
name: "Labor Day",
date: "2026-09-07"
},
{
name: "Thanksgiving Day",
date: "2026-11-26"
}
];
Now your application can reason about the data instead of scattering dates throughout the codebase.
This also makes updating the system much easier.
Observed holidays create another edge case
Here's a classic source of bugs.
Suppose a holiday falls on a weekend.
The actual calendar date and the day on which an institution observes the holiday may be different.
So instead of thinking:
Holiday = Date
it's often better to think:
Holiday
├── Name
├── Actual date
└── Observed date
For example:
{
name: "Example Holiday",
actualDate: "2026-07-04",
observedDate: "2026-07-03"
}
That distinction becomes important whenever an application is trying to answer a question in real time.
Time zones are another trap
Imagine someone checks a website at:
11:30 PM
Are they asking about their local date?
Or the date where the bank is located?
Those aren't necessarily the same thing.
JavaScript's Date object can also create confusion because developers frequently mix local time and UTC.
For example:
new Date()
doesn't mean "the current time everywhere."
It represents a specific instant in time, which then gets interpreted according to a timezone.
For applications dealing with physical locations, timezone awareness should therefore be part of the data model.
A more useful representation might look like:
{
city: "New York",
timezone: "America/New_York",
opens: "09:00",
closes: "17:00"
}
Now the application has enough information to determine whether the current local time falls inside the operating window.
“Open” isn't always binary
Another interesting design problem is that open/closed is sometimes too simplistic.
A better status model could be:
{
status: "open",
reason: null
}
or:
{
status: "closed",
reason: "Federal holiday"
}
or:
{
status: "closed",
reason: "Weekend"
}
This is much more useful to a user.
Compare:
❌ Closed.
with:
✅ Closed today because it is a federal holiday. Normal hours resume tomorrow.
The second answer explains the decision.
Building a better bank-hours architecture
If I were designing a production system for this problem, I'd separate the application into several layers.
Layer 1: Calendar
Responsible for:
Current date
Day of week
Time
Timezone
Layer 2: Holiday engine
Responsible for:
Holiday definitions
Actual dates
Observed dates
Holiday names
Layer 3: Institution rules
Responsible for:
Operating days
Standard hours
Special closures
Branch-specific differences
Layer 4: Status engine
Responsible for turning all of that information into something simple:
{
open: false,
reason: "Weekend"
}
Layer 5: User interface
Finally, the user shouldn't have to understand any of the complexity.
They should be able to ask:
Are banks open today?
This pattern applies far beyond banks
That's probably the most interesting lesson.
The same architecture can be applied to almost any application that needs to understand operating schedules.
Think about:
Restaurants
Government offices
Post offices
Schools
Clinics
Libraries
Retail stores
Delivery services
Stock exchanges
Customer support teams
The underlying problem is similar:
Current time
  +
Location
  +
Calendar
  +
Exceptions
  =
Current operating status
Once you recognize the pattern, you start seeing "opening hours" as a small but legitimate data-engineering problem.
A useful rule for developers
One of my favorite lessons from problems like this is:
Don't model the answer. Model the rules that produce the answer.
Hardcoding:
if (today === "Monday") {
return "Open";
}
models the answer.
Building a calendar, holiday system, timezone layer and operating-hours engine models the rules.
The second approach takes more effort initially, but it's far easier to maintain.
And when someone asks:
"What happens next year?"
you don't have to rewrite the entire application.
Making the interface simple
Despite all this complexity underneath, the frontend can remain extremely simple.
For example:
Are Banks Open Today?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;United States&lt;/p&gt;

&lt;p&gt;🟢 OPEN&lt;/p&gt;

&lt;p&gt;Today is a regular business day.&lt;/p&gt;

&lt;p&gt;Typical hours:&lt;br&gt;
9:00 AM – 5:00 PM&lt;/p&gt;

&lt;p&gt;[Check your state]&lt;br&gt;
Or:&lt;br&gt;
Are Banks Open Today?&lt;/p&gt;

&lt;p&gt;United States&lt;/p&gt;

&lt;p&gt;🔴 CLOSED&lt;/p&gt;

&lt;p&gt;Banks are closed today because of a holiday.&lt;/p&gt;

&lt;p&gt;Next regular business day:&lt;br&gt;
Tuesday&lt;br&gt;
The complexity belongs in the system, not in the user's experience.&lt;br&gt;
That's one reason I built Banks Open Today⁠� around the basic question rather than forcing users to understand banking calendars themselves.&lt;br&gt;
For people specifically looking for U.S. information, the United States bank-hours guide⁠� provides a more focused starting point.&lt;br&gt;
The bigger lesson: real-world software is messy&lt;br&gt;
One of the easiest mistakes when learning programming is assuming that every problem has a clean input and a clean output.&lt;br&gt;
Real applications rarely work that way.&lt;br&gt;
A question that sounds like:&lt;br&gt;
"Is it open?"&lt;br&gt;
can actually depend on:&lt;br&gt;
Date&lt;br&gt;
↓&lt;br&gt;
Day of week&lt;br&gt;
↓&lt;br&gt;
Holiday&lt;br&gt;
↓&lt;br&gt;
Observed holiday&lt;br&gt;
↓&lt;br&gt;
Location&lt;br&gt;
↓&lt;br&gt;
Timezone&lt;br&gt;
↓&lt;br&gt;
Institution&lt;br&gt;
↓&lt;br&gt;
Branch&lt;br&gt;
↓&lt;br&gt;
Special schedule&lt;br&gt;
↓&lt;br&gt;
Current time&lt;br&gt;
↓&lt;br&gt;
Status&lt;br&gt;
That's why projects based on everyday questions can sometimes be surprisingly good engineering exercises.&lt;br&gt;
They force us to deal with the part of software development that tutorials often skip:&lt;br&gt;
exceptions, incomplete information, changing rules and real-world data.&lt;br&gt;
And that's ultimately what makes a simple-looking application interesting to build.&lt;br&gt;
One final thought&lt;br&gt;
The next time you see a website answering a question as simple as "Is it open today?", don't assume there's a trivial if statement behind it.&lt;br&gt;
There might be an entire calendar engine hiding underneath.&lt;br&gt;
And that's a good reminder for developers:&lt;br&gt;
The difficult part of software isn't always producing an answer. Sometimes it's correctly defining what the question actually means.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>productivity</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
