Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Is it possible to auto generated the public holiday of each country (Example: Singapore)? If possible, how.

 

I don't want my user to enter the dates of the public holiday to prevent human errors.

 

Help........

Posted
You can have them in like a text file that comes with your program and have your program read them all in. Or you can hard code them in. I don't think you'd be able to simply... generate them.
Posted

To get auto generation to work you would have to, essentially, find an equation for the calculation of a holiday. And you would have to do this for every holiday you wanted to have available.

 

For example, most holidays are pretty easy. Christmas is December 25. Auto generation for a public holidy that a person would get off from work might entail defining a rule that states something like "Christmas holiday will be on December 25 or the preceding friday if the 25th falls on a weekend." So you'd have to figure out a way to determine if Dec 25 is on a weekend or a weekday and then adjust the holiday.

 

Something like Labor Day would be a little harder. That falls on the first monday in September. You would have to figure out the exact date that occurs...

 

You can definately generate the dates. It's just going to take a little work. I would start by exploring the DateTime class. Also there are already tons of equations out there for determing what day a date is, but that functionality may already be in the DateTime class. I am unsure right now.

 

The next thing you would want to do is identify a simple subset of holidays for a single nation and get them working, starting with the ones that have hard dates (New Year's etc..). Easter will be pretty interesting ( if you know how to read perl, here's one way to do it... perl algorithm

Posted
Easter is something like 'the week after the 3rd full moon in the year'. You would have to double check that, but it gives you an idea.
Posted
For example, most holidays are pretty easy. Christmas is December 25. Auto generation for a public holidy that a person would get off from work might entail defining a rule that states something like "Christmas holiday will be on December 25 or the preceding friday if the 25th falls on a weekend." So you'd have to figure out a way to determine if Dec 25 is on a weekend or a weekday and then adjust the holiday.

 

When dealing with multiple countries though you have to remember not all countries celebrate the same holidays on the same day e.g: christmas on the 25th december isnt celebrated in russia and as such isnt a public holiday

Visit: VBSourceSeek - The VB.NET sourcecode library

 

 

"A mere friend will agree with you, but a real friend will argue."
Posted
When dealing with multiple countries though you have to remember not all countries celebrate the same holidays on the same day e.g: christmas on the 25th december isnt celebrated in russia and as such isnt a public holiday

True.

 

A cool way to handle this might be to use some kind of meta-data of the holdiays for a country and then load that data in at run time. Then your program will always be up to date. To do this you would have to find a way to determine certian reference events (moon cycle in the case of easter). Then your XML hold data like

 

<contry ="usa">
  <holdiay name="christams">
     <date set="true">25</date>
     <work_holiday>true</work_holiday>
  </holdiay>
  <holiday name="easter">
     <date set="false">
        <reference_date>fullMoon3</reference_date>
        <follow_time>7</follow_time>
    </date>
  </holiday>
</country>

This is shot from the hip and is probably not the best representation to handle this. You should consider your data and really think about what you need to store and what you can deduce before you go this route. Maybe you'll want to code equations for as many holidays as you can and then use a file to give set dates and flip holidays on and off for different countries. If you can come up with a meta-representation, that would probably be best becuase it would be very difficult to know or find every holiday for every culture in the world and it would be difficult to make a new release every time you find a new one one, add a new country, or everytime a new holiday is created.

 

Search online. This problem isn't completely new (I'm sure the calendar industry uses something) so there should be a lot of good equations out there similiar to the easter one I linked above. It's just a matter of finding and bringing them together...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...