Quick Search for:  in language:    
Ever,wondered,Calculate,date,easter,Well,here
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Perl Stats

 Code: 65,121. lines
 Jobs: 22. postings

 How to support the site

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for Perl.
Click here to see a screenshot of this code!Validation Subroutines
By Randy McCleary on 7/8

(Screen Shot)

PUSH & POP
By Damian myerscough on 7/6


Click here to see a screenshot of this code!SEND THIS PAGE TO A FRIEND /RESULTS PAGE /SEND E-GREETINGS ** [A MULTIPURPOSE SCRIPT]**
By stephen antony on 7/6

(Screen Shot)

A Example of Sending Email in PerlScript
By Randy McCleary on 7/5


Order Domain site web
By ZeRoHaCk on 7/5


Word list merger
By Mike Brownbill on 7/1


record_gen
By Rishard on 6/28


Very Simple Counter
By Jesse McAllister on 6/27


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Calculating Easter

Print
Email
 
VB icon
Submitted on: 4/29/2003 10:54:24 AM
By: Randy McCleary 
Level: Beginner
User Rating: By 3 Users
Compatibility:5.0 (all versions)

Users have accessed this code 854 times.
 
(About the author)
 
     Ever wondered how to Calculate the date of easter? Well here's a simple Perl script that will just do that. It shows how to get the date of Easter for the current year and for the next 25 Years in the Future.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    =**************************************
    = Name: Calculating Easter
    = Description:Ever wondered how to Calcu
    =     late the date of easter? Well here's a s
    =     imple Perl script that will just do that
    =     . It shows how to get the date of Easter
    =     for the current year and for the next 25
    =     Years in the Future.
    = By: Randy McCleary
    =
    = Inputs:Year
    =
    = Returns:Date Of Easter
    =
    = Assumes:The algorithm is based on the 
    =     algorithm of Oudin (1940) and quoted in 
    =     "Explanatory Supplement to the Astronomi
    =     cal Almanac", P. Kenneth Seidelmann, edi
    =     tor.
    =
    =This code is copyrighted and has    = limited warranties.Please see http://w
    =     ww.Planet-Source-Code.com/vb/scripts/Sho
    =     wCode.asp?txtCodeId=460&lngWId;=6    =for details.    =**************************************
    
    #!/usr/bin/perl -w
    ########################################################################
    # A Simple script that Calculates the date of Easter and shows how
    # to calculate future dates of easter.
    ########################################################################
    use POSIX;
    use strict;
    use CGI qw(:standard);
    use CGI::Carp qw(fatalsToBrowser);
    use Time::Local;
    my ($Year2, $Century, $G, $K, $I, $J, $L, $EasterMonth, $EasterDay, $p);
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = 0;
    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
    my $month_name= 'jan';
    $year += 1900;
    if (param()) {
    	$year = param('y');
    }
    print header;
    print "<b>\n";
    ######################################
    # Print Date of easter This year
    ######################################
    &CalculateEaster;();
    print "</b><br><br>\n";
    ######################################
    # Print the next 25 Years of Easter
    ######################################
    print "Next 25 Years<br>\n";
    for ($p = 1; $p <= 25; $p += 1) {
    	&CalculateEaster;();
    }
    ######################################
    # Subroutine to Calculate the date of
    # Easter for a given year
    ######################################
    sub CalculateEaster {
    	$Year2 = $year + $p;
    	$Century = int $Year2 / 100;
    	$G = $Year2 % 19;
    	$K = int (($Century - 17) / 25);
    	$I = ($Century - int ($Century / 4) - int (($Century - $K) / 3) + 19 * $G + 15) % 30;
    	$I = $I - (int ($I / 28)) * (1 - (int ($I / 28)) * (int (29 / ($I + 1))) * (int ((21 - $G) / 11)));
    	$J = ($Year2 + int ($Year2 / 4) + $I + 2 - $Century + int ($Century / 4)) % 7;
    	$L = $I - $J;
    	$EasterMonth = 3 + int (($L + 40) / 44);
    	$EasterDay = $L + 28 - 31 * (int ($EasterMonth / 4));
    	$month_name = ("January", "February", "March", 
    							"April", "May", "June", "July", 
    							"August", "September", "October", 
    							"November", "December")[$EasterMonth-1];
    	print "Easter is $month_name $EasterDay, $Year2 <br>\n";
    }


Other 12 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
5/6/2003 10:17:04 AM:stephen antony
good work men cool i think you did it 
well as i know the method
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Perl Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.