Re: [PHP] Days until Easter and Christmas

2008-11-18 Thread Aarno Syvänen

Read Wikipedia article computus

On 18 Nov 2008, at 13:42, Nathan Rixham wrote:


Nathan Rixham wrote:

Kevin Waterson wrote:

This one time, at band camp, tedd <[EMAIL PROTECTED]> wrote:

Easter lands on different dates depending upon several different  
factors. For example in Canada it's the day after it is in the  
USA -- I guess Canadians are slower, eh?  :-)


Also, in some religions the date is the full-moon after the  
Equinox and not a specific date. Furthermore, the Equinox does  
not always land on March 21, but sometimes it's March 20 (leap  
year).


So, the key is to find the date of the Vernal Equinox, which as  
you say,
does not always land on March 21. However, every 400 years, it  
does happen
on March 21 7:30am GST. From there, we can derive a base for  
future dates.
Every 4th year is a leap year, and every 4th century, giving 97  
leap days
each 400 years. so (365*400+97)/400 is 365.2425 gives the length  
of each year.

Then the dates can be calculated as follows:

http://phpro.org/examples/Get-Vernal-Equinox.html

Any improvements welcomed

Kind regards
Kevin
just for the sake of madness, many moons ago I wrote this bit of  
code which will create a "datestamp"

1st January 1 (datestamp 1) to 31st December 32767 (datestamp  
11967900)

datestamp(year,month,day)
Turns any date in the valid date range into an integer value
datestamp_parts(datestamp)
Takes input datestamp and returns an array containing the date  
info   */

function datestamp($y=0,$m=0,$d=0) {
   /*
   datestamp(year, month, day)
   year INT | not required | default: current year
   month INT | not required | default: current month
   day INT | not required | default: current day
   called with no values returns the current dates datestamp
   returns false on error
   */
   $datestamp = false;
   $y = $y ? $y : date("Y");
   $m = $m ? $m : date("n");
   $d = $d ? $d : date("j");
   if(checkdate($m, $d, $y)) {
   $datestamp = ((($y-1)*365)+date("z",mktime(1,1,1,$m,$d,2007)) 
+(floor($y/4)-(floor($y/100)-floor($y/400+1;  
if(floor($y/100) == $y/100) && (floor($y/400) == $y/400))) ||  
((floor($y/4) == $y/4) && (floor($y/400) == $y/400)) || ((floor($y/ 
4) == ($y/4)) && !(floor($y/100) == $y/100))) &&  
(date("z",mktime(1,1,1,$m,$d,2000))<60)) {

   $datestamp--; //leapyear adjustment
   }
   }
   return $datestamp;
}
function datestamp_parts($datestamp=0) {
   if($datestamp && ($datestamp < 11967900)) {
   $yd= ((365)+($datestamp-((ceil(($datestamp- 
((floor((($datestamp/365)/4)-floor(($datestamp/365)/ 
100)+floor(($datestamp/365)/400)/365))*(365- 
(floor(((ceil(($datestamp-((floor((($datestamp/365)/4)- 
floor(($datestamp/365)/100)+floor(($datestamp/365)/400)/ 
365))-1)/4)-(floor(((ceil(($datestamp-((floor((($datestamp/365)/4)- 
floor(($datestamp/365)/100)+floor(($datestamp/365)/400)/ 
365))-1)/100)-floor(((ceil(($datestamp-((floor((($datestamp/365)/4)- 
floor(($datestamp/365)/100)+floor(($datestamp/365)/400)/ 
365))-1)/400))); $y = (ceil(($datestamp- 
((floor((($datestamp/365)/4)-floor(($datestamp/365)/ 
100)+floor(($datestamp/365)/400)/365)); $l =  
((floor((ceil(($datestamp-((floor((($datestamp/365)/4)- 
floor(($datestamp/365)/100)+floor(($datestamp/365)/400)/365))/ 
4)-(floor((ceil(($datestamp-((floor((($datestamp/365)/4)- 
floor(($datestamp/365)/100)+floor(($datestamp/365)/400)/365))/ 
100)-floor((ceil(($datestamp-((floor((($datestamp/365)/4)- 
floor(($datestamp/365)/100)+floor(($datestamp/365)/400)/365))/ 
400)))-(floor(((ceil(($datestamp-((floor((($datestamp/365)/4)- 
floor(($datestamp/365)/100)+floor(($datestamp/365)/400)/ 
365))-1)/4)-(floor(((ceil(($datestamp-((floor((($datestamp/365)/4)- 
floor(($datestamp/365)/100)+floor(($datestamp/365)/400)/ 
365))-1)/100)-floor(((ceil(($datestamp-((floor((($datestamp/365)/4)- 
floor(($datestamp/365)/100)+floor(($datestamp/365)/400)/ 
365))-1)/400; if((!$l && $yd>365)) {

   $yd=$yd-365;
   $y++;
   $l=1;
   } elseif($l && $yd>366) {
   $yd=$yd-366;
   $y++;
   $l=0;
   }
   $uy = $l ? 2000 : 2001;
   $m = date("n",mktime(1,1,1,1,$yd,$uy));
   $md = date("j",mktime(1,1,1,1,$yd,$uy));
   $out['year'] = $y;
   $out['month'] = $m;
   $out['month_day'] = $md;
   $out['leapyear'] = $l;
   $out['year_day'] = $yd;
   return $out;
   } else {
   return false;
   }
}
?>
not sure why I'm throwing it in but it sure was interesting trying  
to make it, possibly the single longest line of eye watering code  
ever in there lol!


after more reflection, this should be a task on celebrity php code  
challenge "refactor that"


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] WAP?

2006-11-03 Thread Aarno Syvänen

Perhaps you should start at http://www.kannel.org

Aarno

On 02 Nov 2006, at 22:02, Richard Lynch wrote:


So today I was tasked with converting a PHP SMS solution to a PHP WAP
solution...

My first attempt at running through a Zend tutorial from 2000 was of
limited success...

Apparently, the card tag has gone the way of the dodo or something...

Went looking for the php-wap list at php.net/mailing-lists.php and I
guess it's not there...

I'm about to make some more tries at all this after a meeting with the
boss, and will probably eventually stumble across a good
resource/site/list for PHP+WAP, but...

Anybody want to nudge me in the right general direction?...

Thanks!

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php