• anonymous (unregistered)

    Clearly the author should have used 0 and 1 instead of Y and N. It's much more binary that way!

  • kktkkr (unregistered)

    For a large part of those four years someone somewhere pulled this code out every time he had to schedule anything.

  • (nodebb) in reply to anonymous

    "It's much more binary that way!"

    Yes, but is it more blnary? (Look carefully at the table headings. That's an ell after the b.)

  • Remy Porter (google)

    I think this is the best spam bot ever.

  • Unregistered (unregistered) in reply to Remy Porter

    I think it is a real person who builds complete projects out of code snippets that are found here.

  • JA (unregistered) in reply to Unregistered

    That would be the worst project I could possibly imagine. Code not from one fool's mind, but from the collected works of many fools. I almost hope this is true; I wonder how long it would take before the machine commits suicide.

  • Primary Key (unregistered) in reply to Remy Porter

    It could be that the resulting project is quite good, meaning that those errors won't accumulate but cancel each other out somewhat. So, one bug goes to the left, but the other one goes to the right, the aim still quite close to the bullseye.

    Not sure but it could :-)

  • Tillie (unregistered)

    It's a holiday in the US today, which tracking the dates on which holidays fall is always a complicated, fraught proposition.

    Er, what?

  • I dunno LOL ¯\(°_o)/¯ (unregistered) in reply to anonymous

    But then how would you represent DAY_NOT_FOUND?

    TRWTF is that it doesn't represent holidays, it represents weekdays, something simple enough that it could be a CS homework assignment. I have written full auto-holiday support for a commercial lighting controller, so I know what hard is. (And I still let each holiday be individually disabled.) (And no, I didn't do Easter.)

  • I dunno LOL ¯\(°_o)/¯ (unregistered) in reply to Tillie

    "Last Monday in May" is almost trivial; computing something based on the lunar phase (like Easter) is hard.

  • I'm not a robot (unregistered) in reply to Steve_The_Cynic

    Possibly an abbreviation of "boolean array"?

  • (nodebb) in reply to I dunno LOL ¯\(°_o)/¯

    Easter is hard because there isn't just one algorithm for it. Leaving to one side the point that some liturgical calendars still use the Julian calendar rather than the Gregorian, you still have the difference between the Eastern (aka "Orthodox") and Western (aka "Roman (Catholic)" and/or "(Roman) Catholic" rites and similar.

    Once you choose an algorithm, it does tend, fortunately, to be actually algorithmic in nature.

    But for a real gem, consider French jours fériés: Some are on fixed dates within the year, while others are tied to the Roman Catholic liturgical calendar (Easter Monday, Ascension, Assumption, Pentecost, and so on). (Secondary oddity: despite France being an explicitly secular country, there are no jours fériés associated with any other religion.)

    Fixed-date holidays are just that, on a fixed date. The public holiday for Christmas is the 25th of December, even if the 25th is a Saturday or Sunday. If the first of May ("Fête du Travail" = Labour Day) is on Sunday, then the Fête du Travail is on Sunday, and even less than usual is open. (Lots of things are open on public holidays, except for 1 May, when most things are shut. When it's a Sunday, a few of the otherwise still-open things are shut because it's Sunday as well as the Fête du Travail, and there's almost no point in going out, except for getting some exercise.)

  • Hannes (unregistered) in reply to Unregistered

    Kind of like the "StackOverflow sort" which someone implemented a while back... but only much much worse!

  • Adrian (unregistered)

    Spam!

  • (nodebb)

    I'm guessing this comes from someone who programmed APL systems on a mainframe. You would use arrays and tables of booleans because they were natural for the language and they were cheap (one byte). I used to store substitute teachers' availability as a boolean 3D table dimensioned as (days in a cycle) x (periods in a day) x (nbr of substitute teachers).

    But migrating this to strings is a nice WTF.

  • Ann Onymous (unregistered) in reply to Steve_The_Cynic

    In Ireland it gets more complicated again. You have all the issues in France of fixed and variable dates but with the added fun that the bank holidays roll over. E.g., if Christmas lands on a Saturday, the bank holidays for Christmas and Stephen's Day (the 26th), roll over onto the Monday and Tuesday, so they'll end up on the 27th and 28th rather than the 25th/26th. And there's Halloweeen which is the last (rather than first) Monday in the month. Just for fun.

  • Yazeran (unregistered) in reply to Ann Onymous

    Oh man, bank holidays and in general time calculations never gets old when it comes to WTF's (both in the CS variety but also in the actual societal sense). :-)

    Hearing different countries ways of 'fixing' holidays is almost as fun as watching Tom Scott descend into madness describing time zones....

  • Gene Wirchenko (unregistered)

    Another bit of fun would be when a holiday is added. In the past several years, British Columbia has added a stat, Family Day, which is on the second Monday in February.

    Alberta, an adjacent province, has also added a Family Day. Theirs is on the third Monday in February.

    Why not split the difference and have them both on February 14th? I might be biased on that. I was born on November 5th and might well have been conceived on Valentine's Day.

  • not a robot (unregistered)

    I see nothing fundamentally wrong with a simple lookup table like this. Sure using strings is probably sub-optimal but trying to create one function to rule all the different laws, religions, astronomical bodies and what not is ambitious to say the least

  • anonymous (unregistered)

    Is it my eyes, or does the string for 1995 (and 1996) show no actual holidays (other than Saturdays and Sundays)?

  • Tim Ward (unregistered)

    Holidays these days is dead easy - just scrape them from the appropriate Google Calendar.

  • agreed (unregistered) in reply to not a robot

    I agree. Expecting the table to be maintained years later however is a bit of a WTF. You can't get too far ahead of yourself because in some cases holiday dates are changed

  • Olivier (unregistered) in reply to Ann Onymous

    Toll over holiday is not that hard to program (all holidays in Thailand do roll over, because people have very few vacation), neither is the nth Monday of the month. It is a bit more fun when roll over has to take into account people working 6 days per week (holiday on Saturday, do not work that Saturday) vs. people working 5 days per week (holiday on Saturday, roll over to next Monday).

    Then I think that Easter, Ascention, etc. fall at the same weeks/days interval every year. So once you get the 1st one, you are good for the others. I never checked if it is true for the Buddhist calendar.

  • z f k (unregistered) in reply to I dunno LOL ¯\(°_o)/¯

    They are "holyday-able" days, since weekends are already non-working days (I think).

  • AP (unregistered) in reply to Primary Key

    Just like the Universe. There were a hell lot of left-bugs (matter) and a hell lot of right-bugs (anti-matter), and they cancelled each other. The left-over bugs make up today's Universe, where they are declared as features.

  • Quite (unregistered)

    My own bet nwah was when I maintained a FORTRAN system which, as per this, also needed to be updated every year end to add the holidays. (These were internal company holidays which could be used to inform customers "We are not open for business on dd-MMM-yyyy" sort of thing.) We didn't use the Heath-Robinson technique given here, but what we did do was hardwire the holidays into the source code. Every year we had to expand the array by another one row, and then add to the DATA statement etc. etc., and then extract all the source code (some large amount, possibly of the order of a megabyte, I misremember) and rebuild it. Okay, so we had "tools" to do this, but even those tools had to be checked carefully to make sure they were still doing what they ought to be doing. And then running it took a significant length of time to do, during which time we asked all the users not to run their programs. (Count the WTFs in this process.)

    I had the brillant idea when it was my turn to do this for the first time to create a data file containing all those public holidays, and a subroutine to read it, etc. etc., and it all worked very well: it initialised the data structures on startup. Editing that data file to add new data took a matter of minutes, and run time was negligible. That was when I first encountered the saying "It is better to beg forgiveness than ask permission" -- because ask permission was what I did. "No, you can't," I was told, "we can't spare the manpower."

    The following year I dug out the code I'd written the previous year and just implemented it, quietly updating the user instructions. Nobody noticed.

  • Quite (unregistered) in reply to Gene Wirchenko

    A-ha-ha. My son was born 9 months to the day after my birthday.

  • (nodebb) in reply to Ann Onymous

    Here in Australia we also celebrate Easter (lunar) with rollover holidays (ie most Saturday and all Sunday holidays are moved to the Monday) and a few "first Monday in May" types, as well as regional holidays ("show day" mostly) where certain shires/towns/cities will take a day. Also, a few years ago Easter Monday conflicted with Anzac Day, so "Easter Monday" was actually moved to the Tuesday. Five day long weekend!

  • LzzrdBorth (unregistered)

    blnaryHoliday ?? He's invented a new data type - Booleanary.

  • Ex-lurker (unregistered) in reply to not a robot

    Yeah, as far as WTFs go this one is pretty much salvageable. Add records regarding the next 40 years - I doubt the system will still be used after 20* - , rename the table according to its real contents (weekdays), call it a day. As you said it could be better done in other ways, but it's far from being the worst WTF we get.

    *

    And if they're still using this system after 40 years they deserve to have such a bug unexpectedly appear
    :)

  • gnasher729 (unregistered)

    On Stackoverflow, you find one particular problem in the first days of every year: iOS has a function that returns the year of a date. For example 1/Jan/2017 -> 2017. There is another function that returns the year of the week that the date falls in. The first three days of a year can be part of the last week of the previous year, so "yearOfWeek" for this date may be 2016 (I haven't checked, but this thing happens three out of seven years). You only notice the difference in the first days of the year, and not all years. So code that has run without this problem for 23 months can then go wrong suddenly. And the poor dears can't figure out why.

    And because some countries start their week on Monday and some on Sunday, there is the possibility that it works in your place, but not where the customer lives.

  • airdrummer (unregistered)

    It's "bête noire".

    really? i always thot it was beet nwah...or was it betty noyer?-)

  • anonymous (unregistered)

    In Hong Kong, the holiday rule is REAL complicated, in which TWO calendars are used to determine holidays, so all sane ERP systems would really use a table to store holidays.

    Some holidays are fixed on Gregorian calendar, some are fixed on Chinese calendar (so these holidays are floating on Gregorian calendar), Easter rule, and one (or two) day(s) based on solar term. Chinese calendar and solar term are based on real astronomical observation, so there is not really simple rules that can be implemented...

Leave a comment on “Classic WTF: Time for a tblHoliday”

Log In or post as a guest

Replying to comment #:

« Return to Article