• ANON (unregistered)

    They wanted an easy way, they got an easy way. If they wanted a correct way, they should ask for a correct way.

  • Setabsian (unregistered)

    Frist christmas i gave you my heart...

  • csrster (unregistered)

    Sounds like the real wtf was the spec.

  • Zathras (unregistered)

    There are about 100 weekend days in any given year, and only about 10 Federal holidays, giving a perfectly reasonable accuracy rate of over 90%.

  • Indifferent (unregistered)

    It looks very much like someone started to create a more comprehensive solution and got dragged away before they could complete it.

  • randomdude (unregistered)

    Why do they need a varchar(5) to store something that's at max 3 characters?

  • (cs) in reply to Setabsian
    Setabsian:
    Frist christmas i gave you my heart...
    The very next day, you rolled back the transaction...
  • Lazuly (unregistered)

    For "Maybe"?

  • faoileag (unregistered)

    "Dear John,

    thank you for your fast delivery of IS_HOLIDAY. We will from now on apply that function to your account of our time-tracking system.

    Please keep in mind that from now on, we will need an application for vaccation days, signed by the head of your department, should you prefer not to work on January 1st, July 4th, Thanksgiving and Christmas Day/Boxing Day.

    Thank you for your cooperation, your friendly HR team"

  • S (unregistered) in reply to RaceProUK
    RaceProUK:
    Setabsian:
    Frist christmas i gave you my heart...
    The very next day, you rolled back the transaction...

    This year to save me from tears I'll give it to Robert'); DROP TABLE Students;--

  • faoileag (unregistered) in reply to RaceProUK
    RaceProUK:
    Setabsian:
    Frist christmas i gave you my heart...
    The very next day, you rolled back the transaction...
    This year, to save me from tears...
  • (cs)

    Oracle has another way of screwing this one up a little further. If the global NLS settings are different, 1 and 7 may refer to Monday and Sunday.

    You can imagine my delight when I discovered this because the settings were different in test and production.

  • Mike (unregistered) in reply to faoileag
    faoileag:
    RaceProUK:
    Setabsian:
    Frist christmas i gave you my heart...
    The very next day, you rolled back the transaction...
    This year, to save me from tears...

    ... I'll write it in something SQL

  • Damien (unregistered) in reply to TGV
    TGV:
    Oracle has another way of screwing this one up a little further. If the global NLS settings are different, 1 and 7 may refer to Monday and Sunday.

    You can imagine my delight when I discovered this because the settings were different in test and production.

    That's why I tend to write code that compares the values with "known good" values of the correct day. I.e. if I want to check for a Monday, today's date could be used as the "known good Monday". That way I don't have to care (or enforce) any particular NLS settings.

  • mortfurd (unregistered) in reply to Zathras
    Zathras:
    There are about 100 weekend days in any given year, and only about 10 Federal holidays, giving a perfectly reasonable accuracy rate of over 90%.
    I don't know about you, but I don't count weekends as holidays. The way I see it, it fails 100% on the holidays, and flags 100 days as holidays that aren't holidays at all. 100% Fail.
  • Kevin (unregistered) in reply to Zathras
    Zathras:
    There are about 100 weekend days in any given year, and only about 10 Federal holidays, giving a perfectly reasonable accuracy rate of over 90%.

    90.90(repeated)% actually. But as already been stated, 0% since federal holidays land during the week and this captures 0% them and reports 100% inaccurate results.

  • anonymous B (unregistered)

    That is only true for one Nation, but it doesn't say in the story, where the company is.

  • Nobulate (unregistered)

    I am not available for comments as I am on holiday and will and I accidentally the master file.

    -- Signed The Boss

  • (cs)

    If we assume (dangerous, I know) that "banking holiday" means "day when banks (and/or financial institutions in general) are not open for business, then the function is inadequate in a variety of ways:

    • It accounts for something that might vaguely resemble weekends (no, I don't know how MySQL represents weekdays as numbers, and if it uses the entirely feasible 0-6, then it will have one non-banking day per week, not two...)
    • It does not account for public holidays atall*.
    • Its weekend handling is incompatible with countries like e.g. Israel where the weekend is Friday and Saturday and not Sunday. This might not be a major issue, if we assume (...) that the application will only be used in a country with SatSun weekends.
    • All the discussion here revolves around this idea that public holidays do not fall on weekends. In a global trading system, this assumption is as valid as the internationally-incompatible assumption in the code.

    (Here in France, some public holidays are on fixed dates (examples: Jan-1 (New Year's), May-1 (+/- Labour Day), May-8 (VE Day), Dec-25 (Xmas)). They remain on their respective fixed dates, even if those dates are weekends.)

  • (cs) in reply to Damien
    Damien:
    That's why I tend to write code that compares the values with "known good" values of the correct day. I.e. if I want to check for a Monday, today's date could be used as the "known good Monday". That way I don't have to care (or enforce) any particular NLS settings.
    It was a bit more subtle. I found out because the timestamp conversion was behaving differently on both machines, and not immediately, noooo. It happened after a couple of months, when entering "summer time" (DST). The final solution was to set all the parameters every time a session was opened, something that was also needed for that other WTF: Crystal Reports.
  • Pock Suppet (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    (Here in France, some public holidays are on fixed dates (examples: Jan-1 (New Year's), May-1 (+/- Labour Day), May-8 (VE Day), Dec-25 (Xmas)). They remain on their respective fixed dates, even if those dates are weekends.)
    It's not uncommon to get the nearest weekday off if the holiday lands on a weekend.
  • (cs) in reply to randomdude
    randomdude:
    Why do they need a varchar(5) to store something that's at max 3 characters?
    It's not even a varchar. It's a char, so there is not only the possibility of passing 5 chars, but they're ALWAYS passing 5 chars.

    The real question is why they're returning "Yes"/"No" instead of 1 or 0...

  • Nobulate (unregistered)

    To be clear: holidays are determined by the Luhn algorithm.

  • Foobar (unregistered) in reply to NMe

    No, the real question is why they didn't make it char(14) so they could return "file not found", as any good boolean should.

    Captcha: refoveo: (mangled latin for "see again") a JK Rowling spell that causes the victim to experience deja vu.

  • (cs) in reply to NMe
    NMe:
    randomdude:
    Why do they need a varchar(5) to store something that's at max 3 characters?
    It's not even a varchar. It's a char, so there is not only the possibility of passing 5 chars, but they're ALWAYS passing 5 chars.

    The real question is why they're returning "Yes"/"No" instead of 1 or 0...

    I've seen this a lot, it's like people don't know about SQL bit/boolean fields. Hell even char(1) for Y/N would have been better than this.

  • European dude (unregistered)

    So... Mondays and Sundays are holidays...

  • TheSoftwareDev (unregistered) in reply to randomdude
    randomdude:
    Why do they need a varchar(5) to store something that's at max 3 characters?

    For the eventual case where they can't identify the holiday by their own definition

    RETURN 'MAYBE'
  • faoileag (unregistered) in reply to Pock Suppet
    Pock Suppet:
    Steve The Cynic:
    (Here in France, some public holidays are on fixed dates (examples: Jan-1 (New Year's), May-1 (+/- Labour Day), May-8 (VE Day), Dec-25 (Xmas)). They remain on their respective fixed dates, even if those dates are weekends.)
    It's not uncommon to get the nearest weekday off if the holiday lands on a weekend.
    "not uncommon" as in "the USA and the UK are doing this, so it's not uncommon"?
  • (cs) in reply to Foobar
    Foobar:
    No, the real question is why they didn't make it char(14) so they could return "file not found", as any good boolean should.

    Captcha: refoveo: (mangled latin for "see again") a JK Rowling spell that causes the victim to experience deja vu.

    Where have I heard that before?

  • (cs) in reply to European dude
    European dude:
    So... Mondays and Sundays are holidays...

    When I worked in Sainsburys back in 1979 when the workers used to get consideration, the store used to be closed for business on Sundays and Mondays. Overtime was available for those who wanted it, preparing the store for the start of the shopping week (Tuesday).

  • (cs) in reply to faoileag
    faoileag:
    Pock Suppet:
    Steve The Cynic:
    (Here in France, some public holidays are on fixed dates (examples: Jan-1 (New Year's), May-1 (+/- Labour Day), May-8 (VE Day), Dec-25 (Xmas)). They remain on their respective fixed dates, even if those dates are weekends.)
    It's not uncommon to get the nearest weekday off if the holiday lands on a weekend.
    "not uncommon" as in "the USA and the UK are doing this, so it's not uncommon"?
    More or less. I haven't had an official public-holiday-grade day off for such a thing, and there have been several in the five years I've been living in France. If May-1 occurs on a weekend, I don't get a jour ferié at the beginning of May, and neither does anyone else, with the possible exception of civil servants and/or public transport operators (bus drivers, train drivers, Lille Metro control-room and station staff(*), etc.).

    (*) The Lille Metro has neither drivers nor on-train non-driving staff. There are ticket mafia and other folks who get on the trains sometimes, but most of the time the only people on the trains are passengers.

  • (cs)

    "easy" way...

    This is a database. Can store lots of data. Put in every public holiday date for the period that you are covering and look up if it is in the table.

    Of course we know that sometimes they change the public holiday dates, e.g. in 2012 they put one in for a Royal Wedding and moved another one for the Jubilee.

    Of course if you want to default that all Saturdays and Sundays are public holidays you can do an "or" query.

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to Nobulate
    Nobulate:
    To be clear: holidays are determined by the Luhn algorithm.
    And the Luhnar calendar is why China shuts down for two weeks every February.
  • Basingtoke (unregistered) in reply to randomdude
    randomdude:
    Why do they need a varchar(5) to store something that's at max 3 characters?

    It allows expansion for,say, "YESNO" (A holiday except in some zones) and "NOYES" (a working day, except in some zones).

  • Developer Dude (unregistered) in reply to Zathras

    Yes, a good first approximation.

    (see if you had been sneaky you could have got that "first" in there)

  • quibus (unregistered) in reply to European dude
    European dude:
    So... Mondays and Sundays are holidays...
    No

    (mumble mumble Akismet...)

  • anon (unregistered) in reply to ¯\(°_o)/¯ I DUNNO LOL
    ¯\(°_o)/¯ I DUNNO LOL:
    Nobulate:
    To be clear: holidays are determined by the Luhn algorithm.
    And the Luhnar calendar is why China shuts down for two weeks every February.
    sometimes the holiday is in late January instead.
  • JonC (unregistered) in reply to faoileag
    faoileag:
    Pock Suppet:
    Steve The Cynic:
    (Here in France, some public holidays are on fixed dates (examples: Jan-1 (New Year's), May-1 (+/- Labour Day), May-8 (VE Day), Dec-25 (Xmas)). They remain on their respective fixed dates, even if those dates are weekends.)
    It's not uncommon to get the nearest weekday off if the holiday lands on a weekend.
    "not uncommon" as in "the USA and the UK are doing this, so it's not uncommon"?

    The UK doesn't go for the nearest weekday option. Some of our bank holidays are always on Mondays. We have holidays on the first and last Mondays in May and the last Monday in August.

    Christmas is a bit more complicated. Dec 25th and 26th are holidays, unless either or both of them fall on a weekend. Then days the following week are used as holidays in lieu of the weekend days. e.g. in 2009 Christmas day was a Friday, so that was a holiday. Boxing Day (the 26th) fell on a Saturday, so the actual holiday was on the following Monday. In 2010 Christmas was the Saturday, so Monday and Tuesday the following week were holidays.

  • Hasse de great (unregistered)

    If you take every possible holy day from all places and religions you only need to work a few days per year.

  • (cs) in reply to Hasse de great
    Hasse de great:
    If you take every possible holy day from all places and religions you only need to work a few days per year.

    Possibly!

    Then, there is the complication of what exactly a place is.

    In some Canadian provinces, Boxing Day is a statutory holiday, and in others, it is not.

    In British Columbia, Canada, Easter Monday is not a holiday, but it is for federal government employees including those who work in B.C.

    Sincerely,

    Gene Wirchenko

  • (cs) in reply to Developer Dude
    Developer Dude:
    Yes, a good first approximation.

    (see if you had been sneaky you could have got that "first" in there)

    Yeah, I don't see this as a WTF so much as a stub that was never updated.

  • Sparky (unregistered) in reply to Zathras

    Actually, the false-negative rate would be about 10% (ignoring the possibility of the holidays coinciding with weekends); since it's only wrong at most 10 days a year, the accuracy would be 355/365, or about 97.3%!

    I was expecting some kind of monstrosity with a table containing all official holidays for the next 100 years, or a table containing most days (though some would be missing, of course), with a boolean field for whether or not that particular day would be a holiday. That way, they would be prepared for changed in the number of days in the week, or the addition of days at the end of any month of the year! It's not just GOOD, it's FUTURE-PROOF!

  • Anon cow (unregistered) in reply to NMe
    NMe:
    randomdude:
    Why do they need a varchar(5) to store something that's at max 3 characters?
    It's not even a varchar. It's a char, so there is not only the possibility of passing 5 chars, but they're ALWAYS passing 5 chars.

    The real question is why they're returning "Yes"/"No" instead of 1 or 0...

    Because arrays and stuff are hard.

    The eventual goal was to return one week at a time. The result returned would be more like "YNNNN" or "NNNNY" or "NNNYN" with one digit per weekday. Look at that flexibility, the possibilities are 2^5 (virtually endless).

    Two days are not included in the return string because that would be overkill and you should always look out for things eat eat memory.

    Too bad they never finished. I'm sure the result would have been majestic.

  • Worf (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    If we assume (dangerous, I know) that "banking holiday" means "day when banks (and/or financial institutions in general) are not open for business, then the function is inadequate in a variety of ways: * It accounts for something that might vaguely resemble weekends (no, I don't know how MySQL represents weekdays as numbers, and if it uses the entirely feasible 0-6, then it will have one non-banking day per week, not two...) * It does not account for public holidays *at*all*. * Its weekend handling is incompatible with countries like e.g. Israel where the weekend is Friday and Saturday and not Sunday. This might not be a major issue, if we assume (...) that the application will only be used in a country with SatSun weekends. * All the discussion here revolves around this idea that public holidays do not fall on weekends. In a global trading system, this assumption is as valid as the internationally-incompatible assumption in the code.

    (Here in France, some public holidays are on fixed dates (examples: Jan-1 (New Year's), May-1 (+/- Labour Day), May-8 (VE Day), Dec-25 (Xmas)). They remain on their respective fixed dates, even if those dates are weekends.)

    Except well, banks are increasingly open on Saturdays and some have gone so far to offer limited hour banking on Sundays as well.

    Of course, regular bank holidays they're closed, but weekends, increasing numbers of them are open. And yes, I actually went and did a regular teller deposit on a Sunday. Surprised the heck out of me that it was open.

  • mara (unregistered) in reply to Anon cow
    Anon cow:
    NMe:
    randomdude:
    Why do they need a varchar(5) to store something that's at max 3 characters?
    It's not even a varchar. It's a char, so there is not only the possibility of passing 5 chars, but they're ALWAYS passing 5 chars.

    The real question is why they're returning "Yes"/"No" instead of 1 or 0...

    Because arrays and stuff are hard.

    The eventual goal was to return one week at a time. The result returned would be more like "YNNNN" or "NNNNY" or "NNNYN" with one digit per weekday. Look at that flexibility, the possibilities are 2^5 (virtually endless).

    Two days are not included in the return string because that would be overkill and you should always look out for things eat eat memory.

    Too bad they never finished. I'm sure the result would have been majestic.

    Perhaps it should return NYNNY?

  • Omnitheist (unregistered) in reply to Gene Wirchenko
    Gene Wirchenko:
    Hasse de great:
    If you take every possible holy day from all places and religions you only need to work a few days per year.

    Possibly!

    Then, there is the complication of what exactly a place is.

    In some Canadian provinces, Boxing Day is a statutory holiday, and in others, it is not.

    In British Columbia, Canada, Easter Monday is not a holiday, but it is for federal government employees including those who work in B.C.

    Sincerely,

    Gene Wirchenko

    You obviously err in favor of days off.

  • (cs) in reply to Worf
    Worf:
    Steve The Cynic:
    If we assume (dangerous, I know) that "banking holiday" means "day when banks (and/or financial institutions in general) are not open for business, then the function is inadequate in a variety of ways: * It accounts for something that might vaguely resemble weekends (no, I don't know how MySQL represents weekdays as numbers, and if it uses the entirely feasible 0-6, then it will have one non-banking day per week, not two...) * It does not account for public holidays *at*all*. * Its weekend handling is incompatible with countries like e.g. Israel where the weekend is Friday and Saturday and not Sunday. This might not be a major issue, if we assume (...) that the application will only be used in a country with SatSun weekends. * All the discussion here revolves around this idea that public holidays do not fall on weekends. In a global trading system, this assumption is as valid as the internationally-incompatible assumption in the code.

    (Here in France, some public holidays are on fixed dates (examples: Jan-1 (New Year's), May-1 (+/- Labour Day), May-8 (VE Day), Dec-25 (Xmas)). They remain on their respective fixed dates, even if those dates are weekends.)

    Except well, banks are increasingly open on Saturdays and some have gone so far to offer limited hour banking on Sundays as well.

    Of course, regular bank holidays they're closed, but weekends, increasing numbers of them are open. And yes, I actually went and did a regular teller deposit on a Sunday. Surprised the heck out of me that it was open.

    And that does circle around to the point where regardless of if it's Saturday or Sunday, that doesn't make it a holiday.

  • moz (unregistered) in reply to chubertdev
    chubertdev:
    And that does circle around to the point where regardless of if it's Saturday or Sunday, that doesn't make it a holiday.
    Except when you're actually lying on a foreign beach.

    Or, for the traditionalists, when you're actually going to church.

  • CodeMonkey (unregistered) in reply to faoileag

    I actually did work in an office job once where you didn't get the regular bank or Christmas holidays off - I was so stunned when I found out, I almost asked, "but we do get weekends off, right?"

  • neminem (unregistered)

    Amusingly, one of the first things I did in my out-of-college, professional-programmer-now life was write a generic holiday-checker for an application. It had to be generic, so it included a handful of default holidays, but also the ability to create your own holidays, because different places have different holidays. It included options for "specific date", "[nth] [day of week] of the [month]", etc, and then an optional modification as to what to do if the holiday lands on a weekend.

    And that is when I learned that Easter has a crazy complicated algorithm for when it occurs (which I included), but it's nothing compared to TRWTF, which is how you figure out when Chinese New Year lands (which I didn't include - I just included a hardcoded list of Chinese New Year dates until like 2020, and hopefully someone will remember to add more dates to that list in a few years, as I don't work on that project anymore. :D)

Leave a comment on “Christmas is Cancelled”

Log In or post as a guest

Replying to comment #427213:

« Return to Article