How to infer the year of a date given only the month and day
<p>An interesting algorithmic problem that I have recently stumbled across is how to 'guess' the year that a request was <strong>sent</strong> if the machine that it was received on has a different current time to the month and day contained within the request.</p>

<p>This problem came about as a result of a business requirement for a system that I am working on. My system sits between two parties:</p>

<ul>
<li>The first (called the "initiator") sends a request and inputs the date <strong>excluding the year</strong>.</li>
<li>The second (called the "receiver") requires the request to be passed to them with the date that the initiator input into the request, <strong>including the year</strong>.</li>
</ul>

<p>My system therefore needs to somehow decide which year the request was sent. The inputs as far as I can see are the month/day in the request, and the current time my system. Note this could also occur in the case where the initiator is in a timezone that is <strong>behind</strong> my system's timezone.</p>

<p>A very naive approach would be to simply input the year of my own system in the middle. This would obviously cause bugs around midnight on new year's eve, when the initiator could send a request in 2015 and I receive it in 2016, for example, which would result in the receiver logging the request as being sent a year later than it did.</p>

<p>There are two more caveats to this problem:</p>

<ul>
<li>The initiator may sit in a timezone that is <strong>ahead</strong> of the timezone of my system. This could cause a message that, relative to my system, was sent in 2015, but has a date of January</li>
<li>A request may be constructed on the initiator and given a time/date, but only sent up to two months later (but still containing the original time/date). Thus a request for December of 2015 may only be received on my system in February of 2016.</li>
</ul>