Forum Moderators: coopster

Message Too Old, No Replies

Calendar has Monday as First Day

I would like to set first day to Sunday

         

bumpaw

2:58 pm on May 4, 2004 (gmt 0)

10+ Year Member



I have the jax calendar set up great except the client wants to see Sunday as the first day of the week. I think this is the code that effects it if anyone can figure out how to change it.

if ( ( $cal_year == $now_year ) && ( $cal_month == $now_month ) )
$today_day = $now_day;
else
$today_day = 0;

$days_last_month = gmdate( "d", gmmktime(0,0,0,$cal_month,0,$cal_year ) );
$days_this_month = gmdate( "d", gmmktime(0,0,0,$cal_next_month, 0, $cal_next_year ) );

$first_day_this_month = gmmktime( "0","0","0",$cal_month, "1", $cal_year );
$l_tm = localtime( $first_day_this_month, 1);

//$posx = array();

// what's the weekday of the 1st day of this month?*/
$first_day_pos = $l_tm[ "tm_wday" ];

if ( $first_day_pos == 0 ) $first_day_pos = 7; // convert to Mo=1 to Su=7

$day_num = $days_last_month - ($first_day_pos-2); $class=' class="last_month"';

for ( $y=1; $y<=6; $y++ )
{
echo "<tr>\n";
for ( $x=1; $x<=7; $x++ )
{
if ( ($y==1) && ($x==$first_day_pos) )
{
$day_num = 1; $class="";
}

if ( ($y >1) && ($day_num==$days_this_month+1) )
{
$day_num = 1; $class=' class="next_month"';
}

if ( ($class=="") && ($day_num == $today_day) )$id=' id="today"'; else $id="";
if ( ( $id!=' id="today"') && ($class=="") && ($day_num == $cal_day ) ) $id=' id="selected"';

if ( $class!= "" )
{ $ap1 = ""; $ap2 = ""; }
else
{ $ap1 = '<a href="'.$calendar_open_url."?Y=$cal_year&m=$cal_month&d=$day_num&$ox_tail".'" target="'.$calendar_open_target.'">'; $ap2 = '</a>'; }

if (($booked_events[$day_num]!= 0) && $class=="")
echo '<td'.$class.$id.'>'.$ap1.'<span class="reserved">'.$day_num.'</span>'.$ap2.'</td>'."\n";
else
echo '<td'.$class.$id.'>'.$ap1.$day_num.$ap2.'</td>'."\n";

$day_num++;
}
echo "</tr>\n";
}

coopster

9:26 pm on May 5, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Day of the week returned by localtime returns an array identical to that of the structure returned by the C function call, which starts at 0 (zero). Therefore, you may have to modify your
$first_day_pos
variable:
if ( $first_day_pos == 0 ) { 
$first_day_pos = 7; // convert to Mo=1 to Su=7
} else {
$first_day_pos += 1; // add 1 to get it to work right in your next loop...
}

bumpaw

10:12 pm on May 5, 2004 (gmt 0)

10+ Year Member



coopster you nailed it! Thanks so much.