The difference between the dates in years

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Feb 10 22:28:16 UTC 2024


On Saturday, February 10, 2024 3:11:48 PM MST Brad Roberts via Digitalmars-d-
learn wrote:
> Back when I was doing lots of software developer interviews, one of my
> frequent questions involved date math.  This wasn't because it's
> difficult from a coding standpoint, but that it's NOT a coding problem.
> The key part of the question is realization that it's a requirements
> question.  The thing that makes dates complicated is defining what the
> question actually is.
>
> The topic _seems_ like it should be simple, but the deeper you dig the
> more you realize it's anything but simple.

Indeed. And because it seems simple at first, it's very common for code to
be written which does the wrong thing with regards to dates and times -
often which seems like it does the right thing, because it works a lot of
the time, when in fact, there are edge cases where it definitely does the
wrong thing (e.g. with regards to leap years or DST). And math around months
is a prime area where it's difficult to get right in part because different
people have different requirements depending on the actual problem that
they're trying to solve.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list