billroper: (Default)
billroper ([personal profile] billroper) wrote2004-06-17 05:56 pm
Entry tags:

Fun and Games With Dates

There are dates that are fun. Then there are dates that aren't.

In this case, these aren't dates you go out on, nor are they dates that you eat. They're dates that exist on a calendar.

Right now, the date when I need to finish my current project at work is approaching like an onrushing train and I discover that one of my major problems is figuring out how to convert between dates that exist on a calendar and dates that only a financial guy could love. You see, I need to figure out when events are going to occur, based on contracts that specify real dates that exist on a calendar. Most of the models in our product are based in calendar time, so there's no problem at all finding the real calendar date that matches. (Well, a few small problems, but they're easily solved.)

But there are three kinds of year that we support that don't match up with a real calendar:

12-month years with 360 days
12-month years with 364 days and months containing 4 or 5 weeks
13-month years with 364 days and months that all contain 4 weeks

I know what the easy solution is -- other than not supporting them, which is right out. I'm just trying to convince myself that our users will be ok with the easy solution. (Which is dumping the extra days in the last month of the fiscal year and letting God sort them out. This would be easier if I weren't God in this case.)

[identity profile] tigertoy.livejournal.com 2004-06-17 11:43 pm (UTC)(link)
I hope you're just venting and not looking for advice, because only a pointy-haired boss could actually tell you how to handle such a mess without more information than you've given us.
poltr1: (Default)

Dates on this calendar are closer than they appear

[personal profile] poltr1 2004-06-18 04:39 am (UTC)(link)
Oh hell. I did something like this at my last job, and it was done in both Perl and Excel. Thankfully, it was based on fiscal weeks, which ran from Monday through Sunday, so it was relatively easy to code....once I figured out how to do it. Alas, the source code stayed behind when I left, as per company procedure. But I remember the algorithm.

[identity profile] shannachie.livejournal.com 2004-06-18 07:05 am (UTC)(link)
They have this Irish saying "When God made time, he made enogh of it". although seeing your problem he might have made a little more?
I like the 13 months solution. It is logical. Wasn't it the French revolution that tried to introduce it?

[identity profile] kevinnickerson.livejournal.com 2004-06-18 05:42 pm (UTC)(link)
Isn't there a "Standard Accounting Practice" to deal with this? Throw it back at the accountants and make them tell you in writing what to do. With examples. ("The third day of the first week of the 13th months is May 7th")