Xymon Mailing List Archive search

Bug in holidays calculation

3 messages in this thread

list Tom Schmidt · Tue, 2 Feb 2016 14:34:35 -0700 ·
I have noticed a bug in the holidays feature of Xymon.  I am using Xymon 4.3.24 and have seen it on previous releases as well.  The issue is that the US Holiday of Thanksgiving is not showing the correct date during leap years.  Thanksgiving is the fourth Thursday in November, so is using this entry in holidays.cfg:

Thanksgiving:type=thu month=11 offset=4

This works correctly during non-leap years, but it is a day off during leap years like 2016.  I added these simple entries to holidays.cfg to better show the issue:

November Week 1 Thu:type=thu month=11 offset=1
November Week 2 Thu:type=thu month=11 offset=2
November Week 3 Thu:type=thu month=11 offset=3

When I look at the holidays that it calculates, I get this in the info column:

Holidays 2015/2016 (USA)
November Week 1 Thu	Nov 05
November Week 2 Thu	Nov 12
November Week 3 Thu	Nov 19
Thanksgiving		Nov 26
Christmas Day		Dec 25
New Year's Day		Jan 01
Easter Sunday		Mar 27
Memorial Day		May 30
Independence Day	Jul 04
Labor Day		Sep 05
November Week 1 Thu	Nov 03
November Week 2 Thu	Nov 09
November Week 3 Thu	Nov 16
Thanksgiving		Nov 23

Note that the November 2015 dates are correct, but the November 2016 dates for Week 2 and later are a day early.  Thus it thinks Thanksgiving 2016 is on November 23 instead of the correct November 24 date.

I looked at the source code some, but I could not follow the logic of how it is calculating this date incorrectly.  It is a minor bug only affecting those that use the holidays feature for alerts or look at the holidays table in the info tab.  Can someone figure out why it is not calculating the date offsets correctly?  It only seems to be doing this during leap years.

Thanks...Tom
-- 
Micron Technology, Inc., Confidential and Proprietary

Tom L. Schmidt
Central Engineering System Administrator Lead
Micron Technology, Inc.  http://www.micron.com/
8000 S. Federal Way  P.O. Box 6  Mail Stop 01-351  Boise, Idaho USA 83707-0006
mailto:user-48d3fa8908d4@xymon.invalid
list Japheth Cleaver · Wed, 3 Feb 2016 14:29:57 -0800 ·
quoted from Tom Schmidt

On Tue, February 2, 2016 1:34 pm, Tom Schmidt (tschmidt) wrote:
I have noticed a bug in the holidays feature of Xymon.  I am using Xymon
4.3.24 and have seen it on previous releases as well.  The issue is that
the US Holiday of Thanksgiving is not showing the correct date during
leap years.  Thanksgiving is the fourth Thursday in November, so is
using this entry in holidays.cfg:

Thanksgiving:type=thu month=11 offset=4

This works correctly during non-leap years, but it is a day off during
leap years like 2016.  I added these simple entries to holidays.cfg to
better show the issue:

November Week 1 Thu:type=thu month=11 offset=1
November Week 2 Thu:type=thu month=11 offset=2
November Week 3 Thu:type=thu month=11 offset=3

When I look at the holidays that it calculates, I get this in the info
column:

Holidays 2015/2016 (USA)
November Week 1 Thu	Nov 05
November Week 2 Thu	Nov 12
November Week 3 Thu	Nov 19
Thanksgiving		Nov 26
Christmas Day		Dec 25
New Year's Day		Jan 01
Easter Sunday		Mar 27
Memorial Day		May 30
Independence Day	Jul 04
Labor Day		Sep 05
November Week 1 Thu	Nov 03
November Week 2 Thu	Nov 09
November Week 3 Thu	Nov 16
Thanksgiving		Nov 23

Note that the November 2015 dates are correct, but the November 2016
dates for Week 2 and later are a day early.  Thus it thinks Thanksgiving
2016 is on November 23 instead of the correct November 24 date.

I looked at the source code some, but I could not follow the logic of
how it is calculating this date incorrectly.  It is a minor bug only
affecting those that use the holidays feature for alerts or look at the
holidays table in the info tab.  Can someone figure out why it is not
calculating the date offsets correctly?  It only seems to be doing this
during leap years.

Thanks...Tom

Hi,

This is definitely a bug in the holidays code; I think the *1st* X of the
month is being calculated OK, but others aren't... Unfortunately, my eyes
began to glaze over the further I got into mktime() response parsing :/

Looks like we had this issue four years ago too:
http://lists.xymon.com/archive/2012-January/033507.html


I'll see if I can take a closer look later on.

Regards,
-jc
list Ryan Novosielski · Wed, 3 Feb 2016 17:54:04 -0500 ·
quoted from Japheth Cleaver
On Feb 3, 2016, at 5:29 PM, J.C. Cleaver <user-87556346d4af@xymon.invalid> wrote:
Hi,

This is definitely a bug in the holidays code; I think the *1st* X of the
month is being calculated OK, but others aren't... Unfortunately, my eyes
began to glaze over the further I got into mktime() response parsing :/

Looks like we had this issue four years ago too:
http://lists.xymon.com/archive/2012-January/033507.html

I'll see if I can take a closer look later on.
Thanks, JC. I thought this rang a bell and I see I chimed in a few times about it too over the course of the next year:
http://lists.xymon.com/archive/2013-July/037912.html

I’d forgotten about it, but would love to see it fixed!

--
____ *Note: UMDNJ is now Rutgers-Biomedical and Health Sciences*
|| \\UTGERS      |---------------------*O*---------------------
||_// Biomedical | Ryan Novosielski - Senior Technologist
|| \\ and Health | user-46c89e614701@xymon.invalid - 973/972.0922 (2x0922)
||  \\  Sciences | OIRT/High Perf & Res Comp - MSB C630, Newark
     `'