- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
They wanted an easy way, they got an easy way. If they wanted a correct way, they should ask for a correct way.
Admin
Frist christmas i gave you my heart...
Admin
Sounds like the real wtf was the spec.
Admin
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%.
Admin
It looks very much like someone started to create a more comprehensive solution and got dragged away before they could complete it.
Admin
Why do they need a varchar(5) to store something that's at max 3 characters?
Admin
Admin
For "Maybe"?
Admin
"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"
Admin
This year to save me from tears I'll give it to Robert'); DROP TABLE Students;--
Admin
Admin
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.
Admin
... I'll write it in something SQL
Admin
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.
Admin
Admin
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.
Admin
That is only true for one Nation, but it doesn't say in the story, where the company is.
Admin
I am not available for comments as I am on holiday and will and I accidentally the master file.
-- Signed The Boss
Admin
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:
(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.)
Admin
Admin
Admin
The real question is why they're returning "Yes"/"No" instead of 1 or 0...
Admin
To be clear: holidays are determined by the Luhn algorithm.
Admin
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.
Admin
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.
Admin
So... Mondays and Sundays are holidays...
Admin
For the eventual case where they can't identify the holiday by their own definition
Admin
Admin
Where have I heard that before?
Admin
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).
Admin
(*) 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.
Admin
"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.
Admin
Admin
It allows expansion for,say, "YESNO" (A holiday except in some zones) and "NOYES" (a working day, except in some zones).
Admin
Yes, a good first approximation.
(see if you had been sneaky you could have got that "first" in there)
Admin
(mumble mumble Akismet...)
Admin
Admin
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.
Admin
If you take every possible holy day from all places and religions you only need to work a few days per year.
Admin
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
Admin
Yeah, I don't see this as a WTF so much as a stub that was never updated.
Admin
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!
Admin
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.
Admin
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.
Admin
Perhaps it should return NYNNY?
Admin
You obviously err in favor of days off.
Admin
And that does circle around to the point where regardless of if it's Saturday or Sunday, that doesn't make it a holiday.
Admin
Or, for the traditionalists, when you're actually going to church.
Admin
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?"
Admin
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)