Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Calendars

Reply
Thread Tools

Calendars

 
 
RayL
Guest
Posts: n/a
 
      09-20-2003
I have a calendar related project. Can anyone tell me where I can find
an explanation for the occurence of various holidays? What I mean is
how to know when they will occur for future dates.

Thanks,
Ray

 
Reply With Quote
 
 
 
 
Jeff
Guest
Posts: n/a
 
      09-20-2003
I no longer have a bookmark to my source for these rules, but I've
been using the following code in a database stored procedure for
several years now. The procedure returns the letter "M" for a major
holiday, or "B" for just a bank holiday. Jan to Dec = 1 to 12, Sun to
Sat = 0 to 6. Even if you don't know SPL, it should be easy enough
to translate to Java.

Of course, this is assuming that you are talking about American holidays...

create procedure holiday(d date) returning char(1);

define month int;
define day int;
define week int;
define weekday int;
define i date;

let month = month(d);
let day = day(d);
let weekday = weekday(d);
let week = ((day(d) - 1)/7) + 1;

if (month = 1 and day = 1) then
return "M"; -- New Years
elif (month = 1 and weekday = 1 and week = 3) then
return "B"; -- MLK
elif (month = 2 and weekday = 1 and week = 3) then
return "B"; -- Presidents
elif (month = 5 and weekday = 1 and day > 24) then
return "M"; -- Memorial
elif (month = 7 and day = 4) then
return "M"; -- Independence
elif (month = 9 and weekday = 1 and week = 1) then
return "M"; -- Labor
elif (month = 10 and weekday = 1 and week = 2) then
return "B"; -- Columbus
elif (month = 11 and weekday = 4 and week = 4) then
return "M"; -- Thanksgiving
elif (month = 12 and day = 25) then
return "M"; -- Christmas
end if;

return "";

end procedure;


--
Jeff
jlar310 at yahoo


"RayL" <(E-Mail Removed)> wrote in message news:eUZab.298992$(E-Mail Removed) et...
> I have a calendar related project. Can anyone tell me where I can find
> an explanation for the occurence of various holidays? What I mean is
> how to know when they will occur for future dates.
>
> Thanks,
> Ray
>



 
Reply With Quote
 
 
 
 
David Segall
Guest
Posts: n/a
 
      09-20-2003
"Jeff" <(E-Mail Removed)> wrote:

>I no longer have a bookmark to my source for these rules, but I've
>been using the following code in a database stored procedure for
>several years now. The procedure returns the letter "M" for a major
>holiday, or "B" for just a bank holiday. Jan to Dec = 1 to 12, Sun to
>Sat = 0 to 6. Even if you don't know SPL, it should be easy enough
>to translate to Java.
>
>Of course, this is assuming that you are talking about American holidays...
>
>create procedure holiday(d date) returning char(1);
>
> define month int;
> define day int;
> define week int;
> define weekday int;
> define i date;
>
> let month = month(d);
> let day = day(d);
> let weekday = weekday(d);
> let week = ((day(d) - 1)/7) + 1;
>
> if (month = 1 and day = 1) then
> return "M"; -- New Years
> elif (month = 1 and weekday = 1 and week = 3) then
> return "B"; -- MLK
> elif (month = 2 and weekday = 1 and week = 3) then
> return "B"; -- Presidents
> elif (month = 5 and weekday = 1 and day > 24) then
> return "M"; -- Memorial
> elif (month = 7 and day = 4) then
> return "M"; -- Independence
> elif (month = 9 and weekday = 1 and week = 1) then
> return "M"; -- Labor
> elif (month = 10 and weekday = 1 and week = 2) then
> return "B"; -- Columbus
> elif (month = 11 and weekday = 4 and week = 4) then
> return "M"; -- Thanksgiving
> elif (month = 12 and day = 25) then
> return "M"; -- Christmas
> end if;
>
> return "";
>
>end procedure;

Don't Americans have Easter Holidays?
 
Reply With Quote
 
Brad BARCLAY
Guest
Posts: n/a
 
      09-20-2003
RayL wrote:
> I have a calendar related project. Can anyone tell me where I can find
> an explanation for the occurence of various holidays? What I mean is
> how to know when they will occur for future dates.


I don't know of such a site. What you might want to do instead is to
list out the fixed dates you need (ie: things that occur on a specific
date each year, like New Years Day, Christmas Day, Boxing Day, Canada
Day, etc.), and then see what's left in the "variable" column (Easter
comes to mind -- something like the first full moon after Lent? I'm not
completely sure -- I'm neither Christian nor Catholic), and look them up
specifically.

Brad BARCLAY

--
=-=-=-=-=-=-=-=-=
From the OS/2 WARP v4.5 Desktop of Brad BARCLAY.
The jSyncManager Project: http://www.jsyncmanager.org


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      09-20-2003
On Sat, 20 Sep 2003 14:56:10 GMT, RayL <(E-Mail Removed)>
wrote or quoted :

>I have a calendar related project. Can anyone tell me where I can find
>an explanation for the occurence of various holidays? What I mean is
>how to know when they will occur for future dates.


see http://mindprod.com/holidays.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      09-20-2003
On Sat, 20 Sep 2003 15:57:26 GMT, David Segall <(E-Mail Removed)>
wrote or quoted :

>Don't Americans have Easter Holidays?


package com.mindprod.holidays;

// com.mindprod.holidays.EasterSunday
import com.mindprod.business.BigDate;

/**
* Specific holiday calculator
*/

public class EasterSunday extends HolInfo
{

public String getAuthority()
{
return "Felix Gursky\'s interpretation of:\n"
+ " 1. Christophorus Clavius: Calendarium Gregorianum
Perpetuum.\n"
+ " Cum Summi Pontificis Et Aliorum Principum. Romae, Ex
Officina\n"
+ " Dominicae Basae, MDLXXXII, Cum Licentia Superiorum.\n"
+ " 2. Christophorus Clavius: Romani Calendarii A Gregorio
XIII.\n"
+ " Pontifice Maximo Restituti Explicatio. Romae,
MDCIII.;\n";
}
public int getFirstYear(int base)
{
return 30;
}
public String getName()
{
return "Easter Sunday";
}
public String getRule()
{
return
"The first Sunday after the first full moon after the vernal
equinox.";
}
public int when( int year, boolean shift, int base )
{
if ( !isYearValid(year, base) )
{
return BigDate.NULL_ORDINAL;
}

if ( year <= 1582 )
{
// use the old Julian method described in
// Oudin (1940) as quoted in
// Explanatory Supplement to the Astronomical Almanac, P.
Kenneth Seidelmann, editor.
// picked off the web at
http://www.pip.dknet.dk/~pip10160/cal/node3.html
// calc g golden number - 1;
int g = year % 19;
// calc i the number of days from 21 March to the Paschal
full moon
int i = ((19 * g) + 15) % 30;
// calc j the weekday for the Paschal full moon (0=Sunday,
1=Monday)
int j = (year + year/4 + i) % 7;
// calc l the number of days from 21 March to the Sunday
// on or before the Paschal full moon (a number between -6
and 2
int l = i - j;
// calc Easter month
int mm = 3 + (l+40)/44;
// calc Easter day of month.
int dd = l + 28 - 31 * (mm/4);
int ord = BigDate.toOrdinal(year, mm, dd);
return shiftSatToFriSunToMon(ord, shift);

}
else if ( year >= 1583 )
{
// more elaborate Gregorian method.
int yearIn19YearCycle = (year % 19) + 1;
int century = year/100 + 1;
int x =(3*century)/4 - 12;
int z = (8*century + 5)/25 - 5;
int d = 5*year/4 - x - 10;
int e = (11*yearIn19YearCycle + 20 + z - x) % 30;
if ( ((e == 25) && (yearIn19YearCycle > 11)) || (e == 24) )
{
e++;
}
int n = 44 - e;
if ( n < 21 )
{
n += 30;
}

n += 7 - ((d + n) % 7);
int ord;
if ( n <= 31 )
{
ord = BigDate.toOrdinal(year, 3, n);
}
else
{
ord = BigDate.toOrdinal(year, 4, n-31);
}

return shiftSatToFriSunToMon(ord, shift);
}return BigDate.NULL_ORDINAL;
} // end when.
}

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
RayL
Guest
Posts: n/a
 
      09-20-2003
Thanks to all. I also found JavaWorld Java Tip 44 (I would give you the
URL but I saved the file in .mht format, which is only used by Microsoft
IE and I'm using Linux for email.

Roedy Green wrote:
> On Sat, 20 Sep 2003 14:56:10 GMT, RayL <(E-Mail Removed)>
> wrote or quoted :
>
>
>>I have a calendar related project. Can anyone tell me where I can find
>>an explanation for the occurence of various holidays? What I mean is
>>how to know when they will occur for future dates.

>
>
> see http://mindprod.com/holidays.html
>
> --
> Canadian Mind Products, Roedy Green.
> Coaching, problem solving, economical contract programming.
> See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing calendars to Sunbird Stubby Firefox 3 04-13-2006 12:35 PM
Module for producing HTML calendars by day/week/month Andy Holyer Perl 0 04-12-2006 01:08 PM
One of 12 Calendars DayRender event does not work on PostBack =?Utf-8?B?TWFyaWFubyBQYWRpbGxh?= ASP .Net 0 11-29-2005 04:18 PM
Calendar -- no alarms from hidden calendars William W. Plummer Firefox 4 11-10-2004 07:07 PM
C# & Calendars Antoni Massó Mola ASP .Net 2 05-03-2004 07:15 PM



Advertisments