• (cs) in reply to Bus Raker
    Bus Raker:
    I sure wouldn't want to work for that company.  No holidays!

     

    But according to the table, five days of every week are holidays!
  • Gordo (unregistered) in reply to marvin_rabbit

    The various holidays can be calculated, but it's neither easy nor straightforward for a lot of them. To see how to do it, look at the formulas in the AltCal spreadsheet.

  • (cs)

    He could have used Lewis Carroll's method, which would be a WTF all it's own...
    In pseudocode:

    Given CCYY/MM/DD...
    E = (3-((18-C) MOD 4)) * 2
    F = E + ((Y DIV 12) + (Y MOD 12) + ((Y MOD 12) MOD 4))
    if (Monthname_in_english_begins_or_ends_with_vowel)
    { G = F + (10 - M) + days_in_month_ignoring_leap_years }
    else { G = F + M }
    if (CCYY is a leap year AND MM = (1 or 2) ) then W = G - 1; else W=G;
    switch (W MOD 7) {
    case 0: Sunday
    case 1: Monday
    ...
    case 6: Saturday
    }

    Or just do what everybody else does and use some standard free date calculations library to do it for you.
  • (cs) in reply to marvin_rabbit
    marvin_rabbit:

    Cool!  Can you show me the formula for Easter next?

    Well, I don't do Excel formulas, but here's a fun one:

    Easter is on the first Sunday after the first full moon after the spring equinox. For any given Y = four digit year (now and in the future.. don't ask about those previous to the 1700's and such):
    (all calculations are integer only, no remainder... DIV's, basically)
    c = y / 100
    n = y - 19 * ( y / 19 )
    k = ( c - 17 ) / 25
    i = c - c / 4 - ( c - k ) / 3 + 19 * n + 15
    i = i - 30 * ( i / 30 )
    i = i - ( i / 28 ) * ( 1 - ( i / 28 ) * ( 29 / ( i + 1 ) ) * ( ( 21 - n ) / 11 ) )
    j = y + y / 4 + i + 2 - c + c / 4
    j = j - 7 * ( j / 7 )
    l = i - j
    m = 3 + ( l + 40 ) / 44
    d = l + 28 - 31 * ( m / 4 )

    M and D will then be the month and day of Easter.
  • (cs) in reply to marvin_rabbit
    marvin_rabbit:

    Cool!  Can you show me the formula for Easter next?


    System.DateTime easter = dtmJesusDied.Date.AddDays(2)
  • (cs) in reply to marvin_rabbit

    marvin_rabbit:

    Cool!  Can you show me the formula for Easter next?

     

    Uh, just follow this link, then have fun writing the code yourself: http://www.oremus.org/liturgy/etc/ktf/app/easter.html

  • CalliArcale (unregistered) in reply to Bus Raker
    Bus Raker:
    Sorry every holiday has an exact calculation ...


    True, but most companies don't neccesarily follow the "official" rules, and may insert holidays of their own.  (Anniversary celebration, industry conferences, etc.)  What you're really interested in with a calendar like this isn't when the holidays actually occur.  It's which days the plant will be closed, and that's sometimes a management decision, not a raw calculation.  For instance, if the company offers X holiday days per year, but if several of the core holidays (Independence Day, Christmas, New Years) happen to fall on weekends, they may choose to actually observe the holiday on a convenient weekday.  "Convenient" may not be calculable, unless the company has some kind of rule such as "closest working day to holiday shall be made a holiday".
  • (cs) in reply to Mihai

    >> 365 bytes, what a waste! Packing it to one bit per day would reduce it to 46 bytes

    Actually that's sort-of how we do it, except with one row per date that contains a huge bitmask of holidays, one bit per financial center. An entire date range gets cached for computation and masked for lookup.

    In banking/finance having an accurate and fast way to determine a good business day (past or future) is crucial. Consider that good business days vary widely not just from country to country, but sometimes city to city, or depending upon the definition of a "financial center", or even bank to bank or department to department.  Even weekends aren't the same in the middle-east.

    The definition of what's a holiday must be configurable by the organisation (so you can't rely on a standard API), be variable according to number of factors (currency/financial center), and be looked up fast (for millions of valuations on complex transactions you can't use on a SQL query to check each holiday).

    So this is still a WTF, but only because it's sub-optimal.

  • OCR Solutions, Inc (unregistered) in reply to wbradney

    The best solution is to use a web cam, point it at a calendar, use a robot to manually flip the pages of the calendar, use OCR to determine which days are holidays and write the results to a CSV file.

    This CSV file should be propagated to several load balanced web servers and the results will be wrapped in SOAP functions where you call a isHoliday(DateTime) web service.

    Now, the DateTime value that you pass in should based on the GMT time even if you are in a different time zone.

    The web service returns a trinary variable, true, false, or FileNotFound.

  • (cs) in reply to marvin_rabbit
    marvin_rabbit:
    Bus Raker:

    Jeff S:
    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........


    Holidays are *data* and should be stored in tables. 

    However, as mentioned, it appears that he is simply declaring every weekend a "Holiday" so in that case logic would work, I suppose.

    The guy who wrote this must be a fun guy to hang out with ... except for Monday-Friday or on any actual holiday that falls on a weekday, that is.

     

    Sorry every holiday has an exact calculation ... in Excel for instance they can represented like:

    Memorial Day - Last Monday in May

    =DATEVALUE("5/" & IF(WEEKDAY(DATEVALUE("5/31/" & intYear))>3, 35 -WEEKDAY(DATEVALUE("5/31/" & intYear)),28-WEEKDAY(DATEVALUE("5/1/" & intYear))) & "/" & intYear)


    Cool!  Can you show me the formula for Easter next?


    Silly Marvin_Rabbit.  Easter is a Sunday.
  • (cs) in reply to Bus Raker
    Bus Raker:

    Jeff S:
    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........


    Holidays are *data* and should be stored in tables. 

    However, as mentioned, it appears that he is simply declaring every weekend a "Holiday" so in that case logic would work, I suppose.

    The guy who wrote this must be a fun guy to hang out with ... except for Monday-Friday or on any actual holiday that falls on a weekday, that is.

     

    Sorry every holiday has an exact calculation ... in Excel for instance they can represented like:

    Memorial Day - Last Monday in May

    =DATEVALUE("5/" & IF(WEEKDAY(DATEVALUE("5/31/" & intYear))>3, 35 -WEEKDAY(DATEVALUE("5/31/" & intYear)),28-WEEKDAY(DATEVALUE("5/1/" & intYear))) & "/" & intYear)

    How you want to cache the results depends on your needs.

     

    I sure wouldn't want to work for that company.  No holidays!

     



    Go ahead and use a formula to help you add entries to your holiday table, but to not store it anywhere and rely on dozens of calculations like these "on the fly" probably isn't the most efficient way to go, is it?  Do you really feel that this is "better" than simply storing the value in a table?  Ironically, you will end up using more space just to store and the *formulas* for these holidays rather than probably 10-15 years of actual data ! 
  • (cs) in reply to marvin_rabbit
    marvin_rabbit:
    Bus Raker:

    Jeff S:
    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........


    Holidays are *data* and should be stored in tables. 

    However, as mentioned, it appears that he is simply declaring every weekend a "Holiday" so in that case logic would work, I suppose.

    The guy who wrote this must be a fun guy to hang out with ... except for Monday-Friday or on any actual holiday that falls on a weekday, that is.

     

    Sorry every holiday has an exact calculation ... in Excel for instance they can represented like:

    Memorial Day - Last Monday in May

    =DATEVALUE("5/" & IF(WEEKDAY(DATEVALUE("5/31/" & intYear))>3, 35 -WEEKDAY(DATEVALUE("5/31/" & intYear)),28-WEEKDAY(DATEVALUE("5/1/" & intYear))) & "/" & intYear)


    Cool!  Can you show me the formula for Easter next?

    Why?  It's a Sunday anyways.

    OK ...

    dteEaster = dteGoodFriday + 2

  • Lohan (unregistered) in reply to Mikademus
    Mikademus:
    That threw me off, why are the non-holidays marked "Y"?!


    Who told you it means Yes and No? You assume too much.... it's actually:

    (Yikes, Work!)
    and
    (Now it's PARTY time!)


  • (cs) in reply to Bus Raker
    Bus Raker:
     

    Sorry every holiday has an exact calculation ...



    For most practical purposes, you need more than the official holidays... if management gives Dec 22, 2006 off as a christmas present for the staff, it's not an official holyday but must be considered for work planing. Next year it might be Dec 21; in 2008 there might be no such present because there is too much work to be done. No find a formula for that.
  • (cs) in reply to Jeff S
    Jeff S:
    Bus Raker:

    Jeff S:
    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........


    Holidays are *data* and should be stored in tables. 

    However, as mentioned, it appears that he is simply declaring every weekend a "Holiday" so in that case logic would work, I suppose.

    The guy who wrote this must be a fun guy to hang out with ... except for Monday-Friday or on any actual holiday that falls on a weekday, that is.

     

    Sorry every holiday has an exact calculation ... in Excel for instance they can represented like:

    Memorial Day - Last Monday in May

    =DATEVALUE("5/" & IF(WEEKDAY(DATEVALUE("5/31/" & intYear))>3, 35 -WEEKDAY(DATEVALUE("5/31/" & intYear)),28-WEEKDAY(DATEVALUE("5/1/" & intYear))) & "/" & intYear)

    How you want to cache the results depends on your needs.

     

    I sure wouldn't want to work for that company.  No holidays!

     



    Go ahead and use a formula to help you add entries to your holiday table, but to not store it anywhere and rely on dozens of calculations like these "on the fly" probably isn't the most efficient way to go, is it?  Do you really feel that this is "better" than simply storing the value in a table?  Ironically, you will end up using more space just to store and the *formulas* for these holidays rather than probably 10-15 years of actual data ! 

    In my particular need it was only necessary to create the formulae once (maybe 30 minutes of work), loop through and populate tblHoliday from 1973 to 2073, therefore covering all of the years I expect to be alive, and thus accountable for the systems.  HR gave me an exact list of our holidays and now I can program my digital wrist watch to disable the 7 AM alarm on those days.

  • (cs) in reply to Richard Nixon

    Keep this under your hat, but I think his signature was a joke:

    http://en.wikipedia.org/wiki/Joke

  • EasterBunny (unregistered) in reply to Otto

    Here's a detailed explanation from the US Naval Observatory, which has the exact same formula - and an actual citation for the calculation.

    Remember kids - your sources should be cited!

    http://aa.usno.navy.mil/faq/docs/easter.html

  • (cs) in reply to John Bigboote
    John Bigboote:
    marvin_rabbit:

    Cool!  Can you show me the formula for Easter next?


    System.DateTime easter = dtmJesusDied.Date.AddDays(2)

    VERY NICE!!  I'm grabbing that one for my function library!!

    Thanks!
  • (cs) in reply to EasterBunny

    I wonder if the holiday extraction routine used something like Oracle's "instr" based on the Database's "Day of the Year" calculation, or if it had to retrieve the whole string and parse it.

    And if I were to write such a routine, I'd hope that I'd use a richer information model (I've got at least 26 characters, I can embed a lot of information about what holiday it might be  e.g. N=New Years, M=Memorial Day, P=Presidents Day, V,X=Christmas Eve and Day, B=Boxing Day, Y=NYEve, A,U=sAt,sUn, W=normal workday, etc).  And perhaps a test for "NULL" in the code with a best-effort at the main holidays (corporate declared holidays unavailable) ... with appropriate documentation and disclaimers.

  • (cs) in reply to tiro
    tiro:
    Caching calculations MIGHT be a good approach IF it turns out the calcuation is a bottleneck.


    It might also be a good approach if it turns out the calculation is not a bottleneck.
  • (cs)

    The programmer who wrote this doesn't have the sense he was born with A simple set of questions are needed to decide on updating policy.

    1. Are the holiday rules algorithmic or variable? Variable and can even change at short notice.
    2. Who knows where to find out the rules? The pedantic, office administrator.
    3. What technical understanding is needed for these rules? None, beyond an ability to follow formulae.
    4. Who cares tuppence about these rules? The pedantic, office administrator.
    5. Who's happy maintaining a project written 5 years ago? The pedantic, office administrator.

    Therefore, slap up a table and an editing screen, let the end-users deal with it and be programming something cooler in 2 years time.

    If I want to appear indespensible, I make sure I'm vital for the high profile projects. Not holiday tables!

  • The Anonymous Coward (unregistered) in reply to Bus Raker

    Layer upon layer of unfounded assumption go into this discussion.  Maybe the app using this table cares about Easter (or a day near Easter); maybe not.

    Maybe the "exact formula" for each holiday is applicable; maybe not.  Last couple years, Christmas and New Years have fallen on the weekend.  How arbitrary is the decision of which day we didn't have to work at my office?  Well, this last year, the decision CHANGED (from the Friday before to the Monday after) mid-December.

    Point being, in many business situations, the "holidays" must be treated as data, not code. 

    Exactly how poor the table structure/usage is depends on how the data will be accessed.  I can't think of many cases where this is a good structure to use in a database table, because it strips away the advantages of the database -- i.e. the DBMS's ability to perform the operations on the data for which the DBMS was designed.  A better approach might be to store holiday dates in the table, then at app init time, load the relevant range of dates and build a bitmap (or bytemap, I suppose) in memory.  This would at least make maintaining the table a little less evil.

    The problem of populating for the future... well, I can understand initially only populating a few years into the future (for the same reasons I cited above to explain my view that dates are data, not code).  This type of table creates a periodic maintenance task by its nature; the problem is that apparently there's not even an automated reminder that the table's about to run out of data, much less a useful maintenance interface.

  • The Anonymous Coward (unregistered) in reply to Bus Raker

    Bus Raker:
    dteEaster = dteGoodFriday + 2

    Ok.... and how do I find Good Friday?

    dteEaster - 2 ?

  • (cs)

    God, that's awful.
    And you still have to write some nasty SQL to get the data back out:


    <font size="2">declare @dateToCheck datetime
    set @dateToCheck = '12/29/1995'

    /* use the offset in days into the year as the array index */
    select substring(blnaryHoliday, datediff(dd, convert(datetime, '1/1/' + cast(year(@dateToCheck) as char)), @dateToCheck) + 1, 1)
    from tblHoliday
    where intYear = year(@dateToCheck)</font>

  • (cs) in reply to Bus Raker
    Bus Raker:

    Jeff S:
    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........


    Holidays are *data* and should be stored in tables. 

    However, as mentioned, it appears that he is simply declaring every weekend a "Holiday" so in that case logic would work, I suppose.

    The guy who wrote this must be a fun guy to hang out with ... except for Monday-Friday or on any actual holiday that falls on a weekday, that is.

     

    Sorry every holiday has an exact calculation ... in Excel for instance they can represented like:

    Memorial Day - Last Monday in May

    =DATEVALUE("5/" & IF(WEEKDAY(DATEVALUE("5/31/" & intYear))>3, 35 -WEEKDAY(DATEVALUE("5/31/" & intYear)),28-WEEKDAY(DATEVALUE("5/1/" & intYear))) & "/" & intYear)

    How you want to cache the results depends on your needs.

     

    I sure wouldn't want to work for that company.  No holidays!

     


    What about Easter?

    "Easter Sunday is the Sunday following the Paschal Full Moon (PFM) date for the year. "

    VB code (copied from http://www.assa.org.au/edm.html#Method):

    Sub EasterDate (d, m, y)
    

    ' EASTER DATE CALCULATION FOR YEARS 1583 TO 4099

    ' y is a 4 digit year 1583 to 4099 ' d returns the day of the month of Easter ' m returns the month of Easter

    ' Easter Sunday is the Sunday following the Paschal Full Moon ' (PFM) date for the year

    ' This algorithm is an arithmetic interpretation of the 3 step ' Easter Dating Method developed by Ron Mallen 1985, as a vast ' improvement on the method described in the Common Prayer Book

    ' Because this algorithm is a direct translation of the ' official tables, it can be easily proved to be 100% correct

    ' This algorithm derives values by sequential inter-dependent ' calculations, so ... DO NOT MODIFY THE ORDER OF CALCULATIONS!

    ' The </STRONG> operator may be unfamiliar - it means integer division ' for example, 30 \ 7 = 4 (the remainder is ignored)

    ' All variables are integer data types

    ' It's free! Please do not modify code or comments! ' ========================================================== Dim FirstDig, Remain19, temp 'intermediate results Dim tA, tB, tC, tD, tE 'table A to E results

    FirstDig = y \ 100 'first 2 digits of year Remain19 = y Mod 19 'remainder of year / 19

    ' calculate PFM date temp = (FirstDig - 15) \ 2 + 202 - 11 * Remain19

    Select Case FirstDig Case 21, 24, 25, 27 To 32, 34, 35, 38 temp = temp - 1 Case 33, 36, 37, 39, 40 temp = temp - 2 End Select temp = temp Mod 30

    tA = temp + 21 If temp = 29 Then tA = tA - 1 If (temp = 28 And Remain19 > 10) Then tA = tA - 1

    'find the next Sunday tB = (tA - 19) Mod 7

    tC = (40 - FirstDig) Mod 4 If tC = 3 Then tC = tC + 1 If tC > 1 Then tC = tC + 1

    temp = y Mod 100 tD = (temp + temp \ 4) Mod 7

    tE = ((20 - tB - tC - tD) Mod 7) + 1 d = tA + tE

    'return the date If d > 31 Then d = d - 31 m = 4 Else m = 3 End If

    End Sub

     
    
    

    How about custom Holidays like parent-teacher conference day in a school system?

     

  • (cs) in reply to jsmith

    Oops, sorry.  I giot all excited and replied before I read page 2 and saw that a million other people already posted Easter.

  • Funky Town (unregistered) in reply to jsmith

    It would have been much better to use 1111!!!111111111111!!!!1one!!11!onehundredandeleven.

  • (cs) in reply to John Smallberries
    John Smallberries:
    God, that's awful.
    And you still have to write some nasty SQL to get the data back out:


    <font size="2">declare @dateToCheck datetime
    set @dateToCheck = '12/29/1995'

    /* use the offset in days into the year as the array index */
    select substring(blnaryHoliday, datediff(dd, convert(datetime, '1/1/' + cast(year(@dateToCheck) as char)), @dateToCheck) + 1, 1)
    from tblHoliday
    where intYear = year(@dateToCheck)</font>


    It's not as bad as all that.
    <font size="2">select
        substring(
            blnaryHoliday,
            datepart(dayofyear, @dateToCheck),
            1
        ) 

    from tblHoliday
    where intYear = year(@dateToCheck)</font>

    It's likely that there's a Calender.aspx page somewhere that shows a month or even a year at once. This could retrieve the single row for that year and split it into a character array for easy lookups.
  • (cs) in reply to The Anonymous Coward
    Anonymous:

    Bus Raker:
    dteEaster = dteGoodFriday + 2

    Ok.... and how do I find Good Friday?

    dteEaster - 2 ?

    You are all making it harder than it really is.

    Good Firday is the day before the end of passover. Easter is the day after.

    Passover is ALWAYS the 21st day of the first month. (Exodus 12:18 - look it up if you don't believe me)

    See how easy that is? (Just switch everyone to the Hebrew calender and things will be much simpler, (Other than the leap month they throw in every few years)

  • (cs) in reply to Sam
    Anonymous:
    ...Of course, logic works for weekends.  Is it just me who only sees weekends defined on this chart?
    <font size="5">Y</font>ou youngster!  There were no holidays back in 1995.
  • (cs) in reply to John Bigboote
    John Bigboote:
    Ametheus:
    When did Christmas stop being a holiday?


    When the Christmas-hating liberal media got hold of the calendar industry.

    No no no, when the Catholic hating Protestant religions banned the practice. In short back in the 1600s. (There are still a few left that have nothing to do with Christmas, but most have given in - the celebration may not be biblical, but everyone thinks it is)

  • mu (unregistered)

    if you ask the question can i book a holliday on X day it makes more sence =)

  • (cs) in reply to mu

    Noobs. Use PHP:
    $easter = easter_date();

    i'm not kidding
    http://au3.php.net/manual/en/function.easter-date.php




    Oh and Richard Nixon (if that IS your real name :p)
    "Mayonnaise is generally said to have been created by the chef of Louis François Armand du Plessis, duc de Richelieu in 1756, to celebrate the Duke's victory over the British at the port of Mahon"

  • pissed (unregistered)

    I found this site about 3 weeks ago, been reading a lot of the wtfs. Very entertaining stuff, lots of funny/insightful comments.

    ...and I'm fucking dumbfounded that little shits like the inimitable "Paula" or other mouth-breather wank-offs like the one responsible for this wtf actually continue to get paid for their incompetence when I can't even get a fucking interview.

    And yes, I'm much, much, better than the morons responsible for the "topics" discussed here, and no, that isn't saying much.

    The real WTF is that there are fuckups out there who are so incompetent at design/programming/development/basic problem solving that their profession is not developing software; it's being a fuckup.

    And they get paid for it.

    And I can't even get a fucking interview.

    Un-what-the-fucking believable.

  • (cs) in reply to Bus Raker
    Bus Raker:
    marvin_rabbit:
    Bus Raker:

    Jeff S:
    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........


    Holidays are *data* and should be stored in tables. 

    However, as mentioned, it appears that he is simply declaring every weekend a "Holiday" so in that case logic would work, I suppose.

    The guy who wrote this must be a fun guy to hang out with ... except for Monday-Friday or on any actual holiday that falls on a weekday, that is.

     

    Sorry every holiday has an exact calculation ... in Excel for instance they can represented like:

    Memorial Day - Last Monday in May

    =DATEVALUE("5/" & IF(WEEKDAY(DATEVALUE("5/31/" & intYear))>3, 35 -WEEKDAY(DATEVALUE("5/31/" & intYear)),28-WEEKDAY(DATEVALUE("5/1/" & intYear))) & "/" & intYear)


    Cool!  Can you show me the formula for Easter next?

    Why?  It's a Sunday anyways.

    OK ...

    dteEaster = dteGoodFriday + 2

    brillant!

  • (cs) in reply to pbounaix

    Better yet:

    $days = array("TRUE","TRUE","TRUE",......"TRUE","TRUE","TRUE","FALSE")

    rawurlencode(base64_encode(serialize($days)))

  • bescrooged (unregistered) in reply to Ametheus

    Ametheus:
    When did Christmas stop being a holiday?

    BAH! HAMBUG!

    Answer:

    (when companies started to scrooge around for cheap programmers)

  • (cs)

    "It's a Feature" wrote:

    > Most holidays can be mathematically calculated (3rd Monday of January, for example,
    > for Martin Luther King's birthday), but some are rather complex in their formulas
    > (every try to calculate Easter?)


    There is perfectly good source code freely available for computing Easter Sunday. From this date, all Easter-related holidays can be easily calculated.


    Been there, done that.

  • gyp (unregistered)

    Well, some month ago I actually did something just like this -- when I looked at it I first thought some of my colleagues'd sent it in :) Trying to protect the original author and, OK, even myself: there are situations when it perfectly makes sense to use such a scheme. The company I'm working for provides transport and relocation services for mostly European and Amercian customers (using the Gregorian calendar) in around 10-20 countries in Asia and in the Middle-East (sometimes using totally different calendars), and these customers and the management here just wants to know when not to travel in those countries to do businness. And when you have countries like Afghanisthan, where they have single-day weekends on Fridays or Uzbekistan with "the second Wednesday after the first blossom of the sacred Oak"-type holidays, or even Hungary here, where they tend to create 4-day weekends upon govermental decision made some months before by working off the previous Saturday when a public holiday is on a Tuesday or Thurstday in the picture, it gets a bit more complicated than to use getDateofWeek() to find out if a day's a weekend or not. So, you have the choice of either buying expensive yet not guaranteed-to-be-correct public holiday databases from various suppliers (supposably employing some monkeys spending their days fetching all the information from obscure govermental sites), or can get your local office managers (who really should know all this stuff to plan their businness) to manually tick in the holidays at the beginning of each year or when their date gets fixed. Sure, they have "copy from previous year" and "preset weekends" features, but in the end, days will have to be picked one-by-one.

    And even the uses of this table confirm the use of a bitmap-like structure: it gets used in calendar-like displays (which should simply get a holiday/not holiday like information for each day); and holiday-measuring and tracking for the company's employees, which is so complex anyways due the part-day calculations (gosh, they needed 0.01 workday precision and I had to consider coffee and lunch breaks!) and the potential need to join this with the punch system information using some fuzzy logic that it couldn't practically be done in SQL queries, only in program code -- which also needs bitmap-like data.

    So, for me, it's not such a big WTF at all out of context like here. Or maybe I'm just trying to convince myself that I did not do something worth a Daily WTF post -- at least I really had to tell myself "yeah, I know it's ugly but it really makes sense here" for hours back then before finally implementing this :)

  • Will Varfar (unregistered) in reply to wbradney

    Absolutely.

    Sad that I had to browse the whole first side of comments to find someone who understood some of the reasons why this might be a good idea and not a WTF at all.

    Although I don't think this is sub-optimal.  It would be easy for a non-techie to understand and even edit this field as-is as necessary, rather than needing any fancy calander tool.

    I really can't see the WTF here folks.

  • My Name (unregistered) in reply to Will Varfar
    Anonymous:
    It would be easy for a non-techie to understand and even edit this field as-is as necessary, rather than needing any fancy calander tool.


    A non techy screwing around directly in the database? Oh now that's a good idea... And how would the non techy do that without a fancy database tool? Via the command line and directly with SQL statements? Oh you might say they can enter that data into a text file, excel or word file and then you'd have a tool to insert it into the database, but why not write a good tool, which supports entering holidays (maybe with pre-picking fixed ones and so on), in the first place? Yeah, there are situations where you can't get a good tool to be used because your partners/customers are to stubborn or whatnot, but that doesn't make the approach less stupid. It just get's a necessary evil to use stupid ways to do things O_o

    BTW:
    Storing this information as Y and N doesn't help the readability in my book. Proofreading after you're done to check if you didn't do mistakes must be horrid. But that's just another story...
  • TC (unregistered) in reply to Otto

    Easter is not a problem because it's by formula (it's not astronomically defined - the equinox and full moon in question are defined by formula).

    That said, then you have to deal with the churches who use the revised julian calendar, celebrate Epiphany, and have easter on a different day. Fortunately the revised julian calendar is otherwise identical for the next couple hundred years.

    Then you get a lot of calendars which are calculated astronomically (such as the Chinese one). And a whole lot of calendars are calculated astronomically (the lunar ones, for one), so Islamic holidays can't be calculated by formula indefinitely, though you may find one that seems to fit for the next howevermany years.

    And then you have leap-months. Depending on which rules you calculate those by, your holidays may be off by an entire month.

    CAPTCHA=BOZO

  • (cs) in reply to My Name
    Anonymous:
    Storing this information as Y and N doesn't help the readability in my book. Proofreading after you're done to check if you didn't do mistakes must be horrid. But that's just another story...


    True enough.  Although, as others have pointed out, this isn't really a WTF (with the possible exception of using 'Y' for workdays in a column described as 'binaryHoliday').  There are very good and valid reasons for storing this, not least of which is the need to deal with arbitrary holidays that can't be calculated.

    It's missing any kind of country / financial centre indicator, so it probably only ever had to deal with one country - again, not really a WTF.  And it obviously doesn't deal with half-day holidays terribly well (unless they have 'M' and 'A' flags, which would seem a reasonable approach, although unlikely to make binaryHoliday a more useful name than it already is).

    I've seen stuff like this before, it's a compact, useful and relatively efficient way of storing stuff.  Add a couple of stored procedures for querying a particular date and setting holiday status for a particular date and you don't ever need to worry about it again.  Just go off and program something interesting.

    Misnamed column using RPN.  What's the fuss all about?

    Simon
  • (cs) in reply to marvin_rabbit

    This is only the 1st page of about 353,000 returned by Google

        http://users.chariot.net.au/~gmarts/eastalg.htm

    Any holiday that's defined like "nth something after nth something" (like 2nd Monday of May, or 40 days after something else) can be calculated.

    What's trickier are local holidays, probably any little town have at least 1 local holiday per year.

    And if your company is multi-national you have to know about holidays in other countries too.

    And than, we have things like half-holidays (you only work in the morning), this can happen (or not) if an holiday falls in a Friday, much of the times this is decided only a few days before.
    Ant there's things like bank holidays, where only the banks are closed.
    So you'll have to know the type of holiday too.

    New holidays pop up, others are removed... The only way is to have a holidays table like:

    MMDD HOLYDAY_TYPE DESCRIPTION COUNTRY PLACE

    If you keep tables about local holidays most of this table can be filled by program on January the 1st but there will always be the need to hand edit the data.<o:p></o:p>

    <!--[if !supportEmptyParas]--> <!--[endif]--><o:p></o:p>




  • Bob_ (unregistered) in reply to pissed
    Anonymous:

    ...and I'm fucking dumbfounded that little shits like the inimitable "Paula" or other mouth-breather wank-offs like the one responsible for this wtf actually continue to get paid for their incompetence when I can't even get a fucking interview.

    And yes, I'm much, much, better than the morons responsible for the "topics" discussed here, and no, that isn't saying much.
    ...


    You know, thats an explanation in itself...
  • wang (unregistered) in reply to John Smallberries

    John Smallberries:
    God, that's awful.
    And you still have to write some nasty SQL to get the data back out:


    <FONT size=2>declare @dateToCheck datetime
    set @dateToCheck = '12/29/1995'

    /* use the offset in days into the year as the array index */
    select substring(blnaryHoliday, datediff(dd, convert(datetime, '1/1/' + cast(year(@dateToCheck) as char)), @dateToCheck) + 1, 1)
    from tblHoliday
    where intYear = year(@dateToCheck)</FONT>

     

    or

    declare @date datetime

    set @date = getdate()

    select substring(binaryHoliday, datepart(dy, @date), 1)

    <FONT size=2>from tblHoliday
    where intYear = year(@<FONT face="Times New Roman" size=3>date</FONT>)</FONT>

    <FONT size=2></FONT> 

    <FONT size=2>Not that bad really.</FONT>


  • (cs) in reply to stephen
    Anonymous:
    Mikademus:
    That threw me off, why are the non-holidays marked "Y"?!

    easy:
    yes == yes, it is not a holiday
    no == no, it is not not a holiday


    Sir! You just used a double negative! </fanboy>
  • MysteryMen (unregistered) in reply to wunderkind
    wunderkind:
    Anonymous:
    The really funny thing is that it should be called "tblWeekends".


    You're close, but not quite there.

    It SHOULD be called "tblWeekdays"


    Not even that...

    The RIGHT name would be "tblWorkdays"
  • mysticwhiskey (unregistered) in reply to Kiwi
    Anonymous:
    Casiotone:
    blnaryHoliday?

    booleanary?


    boolean array maybe


    Booleanniversary?
  • (cs) in reply to Maurits
    Maurits:


    It's not as bad as all that.
    <font size="2">select
        substring(
            blnaryHoliday,
            datepart(dayofyear, @dateToCheck),
            1
        ) 

    from tblHoliday
    where intYear = year(@dateToCheck)</font>


    Dammit, I quickly looked for a "dayofyear" function and didn't find it, so I assumed I was thinking of some other sql implementation. My WTF for reinventing that wheel.

Leave a comment on “Time for a tblHoliday”

Log In or post as a guest

Replying to comment #67444:

« Return to Article