Re: Date Calc

From: Date: Mon, 25 Aug 2003 01:52:29 +0000
Subject: Re: Date Calc
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-7388@lists.php.net to get a copy of this message
OK. my problem on date calc is _partially_ solved. but i am curious and would appreciate suggestion to tightenup the code. here goes -- php script start -- $month = 1; $year = 1970; $calmon = $cal->getCalendarMonth($month,$year); $tpl->assign("days",$calmon); -- php script end -- -- smarty tpl start -- {section name=week loop=$days} <tr> {section name=dow loop=$days[week]} <td valign=top align=center> <font class=answered-hi>{$days[week][dow]|date_format:"%d"}</font> </td> {/section} </tr> {/section} -- smarty tpl end -- that will produce output: (1st column is Monday and xx are blanks) xx xx xx xx 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 01 !! noticed that 29th, 30th and 31st Dec are missing. same goes for 1st Jan. these are replaced with blanks (marked with xx above). taking out the |date_format:"%d" from template will solve this, with output: (1st column is monday) 19691229 19691230 19691231 19700101 19700102 19700103 19700104 19700105 19700106 19700107 19700108 19700109 19700110 19700111 19700112 19700113 19700114 19700115 19700116 19700117 19700118 19700119 19700120 19700121 19700122 19700123 19700124 19700125 19700126 19700127 19700128 19700129 19700130 19700131 19700201 so i have to tweak the php script and use substr to get just the day portion with: -- php script start -- $month = 1; $year = 1970; $calmon = $cal->getCalendarMonth($month,$year); $numweeks = $cal->weeksInMonth($month,$year); for ($weeks=0;$weeks<$numweeks;$weeks++) { for ($days=0;$days<7;$days++) { $d = $calmon[$weeks][$days]; $calmon[$weeks][$days] = substr($d,-2); } } $tpl->assign("days",$calmon); ?> -- php script end -- would appreciate if ppl can explain this. -- Quoting Stefan Neufeind <stefan@neufeind.net>: > What is not correct? Could you give a 10-line-example with current > output and desired output, please? Will have a look. > > On 23 Aug 2003 at 12:24, Sn!per wrote: > > > i noticed that Date_Calc is not able to generate correctly dates > > before Feb.1970 how do i remedy this? > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > --------------------------------------------------- Sign Up for free Email at http://ureg.home.net.my/ ---------------------------------------------------

« previous php.pear.general (#7388) next »