go-utils
[ class tree: go-utils ] [ index: go-utils ] [ all elements ]

Source for file Date.class.inc.php

Documentation is available at Date.class.inc.php

  1. <?php
  2. /**
  3.  * Copyright Intermesh
  4.  *
  5.  * This file is part of Group-Office. You should have received a copy of the
  6.  * Group-Office license along with Group-Office. See the file /LICENSE.TXT
  7.  *
  8.  * If you have questions write an e-mail to info@intermesh.nl
  9.  *
  10.  * @version $Id: Date.class.inc.php 1248 2008-10-27 10:00:59Z mschering $
  11.  * @copyright Copyright Intermesh
  12.  * @author Merijn Schering <mschering@intermesh.nl>
  13.  */
  14.  
  15. /**
  16.  * Define some constants
  17.  */
  18. if(!defined('REPEAT_NONE'))
  19. {
  20.     define('REPEAT_NONE''0');
  21.     define('REPEAT_DAILY''1');
  22.     define('REPEAT_WEEKLY''2');
  23.     define('REPEAT_MONTH_DATE''3');
  24.     define('REPEAT_MONTH_DAY''4');
  25.     define('REPEAT_YEARLY''5');
  26. }
  27.  
  28.  
  29. /**
  30.  * This class has functions that handle dates and takes the user's date
  31.  * preferences into account.
  32.  *
  33.  * @copyright Copyright Intermesh
  34.  * @version $Id: Date.class.inc.php 1248 2008-10-27 10:00:59Z mschering $
  35.  * @package go.utils
  36.  * @since Group-Office 3.0
  37.  */
  38.  
  39. class Date
  40. {
  41.     /**
  42.      * Converts a Group-Office date to unix time.
  43.      *
  44.      * A Group-Office date is formated by user preference.
  45.      *
  46.      * @param    string $date_string The date string formated in the user's preference
  47.      * @access public
  48.      * @return int unix timestamp
  49.      */
  50.  
  51.  
  52.     public function byday_to_days($byday)
  53.     {
  54.         $days_arr explode(','$byday);
  55.  
  56.         $days['sun'in_array('SU'$days_arr'1' '0';
  57.         $days['mon'in_array('MO'$days_arr'1' '0';
  58.         $days['tue'in_array('TU'$days_arr'1' '0';
  59.         $days['wed'in_array('WE'$days_arr'1' '0';
  60.         $days['thu'in_array('TH'$days_arr'1' '0';
  61.         $days['fri'in_array('FR'$days_arr'1' '0';
  62.         $days['sat'in_array('SA'$days_arr'1' '0';
  63.  
  64.         return $days;
  65.     }
  66.  
  67.  
  68.     /**
  69.      * Calculates the next occurence of a recurring event
  70.      *
  71.      * @param int $first_occurence_time The time this events occurs for the first time.
  72.      * @param int $start_time The next occurence returns will happen after this time.
  73.      * @param string $rrule The iCalendar rrule
  74.      * @param boolean $local_time Set to true if the days in the url are not in GMT but local time
  75.      * @return int 
  76.      */
  77.     public static function get_next_recurrence_time($first_occurence_time$start_time$rrule$local_time=false)
  78.     {
  79.         global $GO_CONFIG;
  80.  
  81.         //go_log(LOG_DEBUG, date('r',$start_time));
  82.  
  83.         require_once($GO_CONFIG->class_path.'ical2array.class.inc');
  84.         $ical2array new ical2array();
  85.  
  86.         if(!$rrule $ical2array->parse_rrule($rrule))
  87.         {
  88.             //Recurrence rule is not understood by GO, abort
  89.             return false;
  90.         }
  91.  
  92.  
  93.  
  94.         if(!isset($rrule['FREQ']))
  95.         {
  96.             return false;
  97.         }
  98.  
  99.         //if the requested start
  100.         if($start_time $first_occurence_time)
  101.         $start_time $first_occurence_time-1;
  102.             
  103.         //we cannot simply return the first_occurrence_time because a recurring event
  104.         //can start on a day that it doesn't occur on.
  105.  
  106.         if (isset($rrule['UNTIL']))
  107.         {
  108.             if($event['repeat_end_time'$ical2array->parse_date($rrule['UNTIL']))
  109.             {
  110.                 $event['repeat_forever']='0';
  111.                 $event['repeat_end_time'mktime(0,0,0date('n'$event['repeat_end_time'])date('j'$event['repeat_end_time'])+1date('Y'$event['repeat_end_time']));
  112.             }else
  113.             {
  114.                 $event['repeat_forever'1;
  115.             }
  116.         }elseif(isset($rrule['COUNT']))
  117.         {
  118.             //figure out end time later when event data is complete
  119.             $event['repeat_forever'1;
  120.             $event_count intval($rrule['COUNT']);
  121.             if($event_count==0)
  122.             {
  123.                 unset($event_count);
  124.             }
  125.         }else
  126.         {
  127.             $event['repeat_forever'1;
  128.         }
  129.  
  130.         $event['repeat_every']=isset($rrule['INTERVAL']$rrule['INTERVAL'1;
  131.  
  132.         if($event['repeat_every']==0)
  133.         return false;
  134.  
  135.         $occurence_time=0;
  136.  
  137.         $event['start_time']=$first_occurence_time;
  138.  
  139.  
  140.  
  141.         $day_db_field[0'sun';
  142.         $day_db_field[1'mon';
  143.         $day_db_field[2'tue';
  144.         $day_db_field[3'wed';
  145.         $day_db_field[4'thu';
  146.         $day_db_field[5'fri';
  147.         $day_db_field[6'sat';
  148.  
  149.         switch($rrule['FREQ'])
  150.         {
  151.  
  152.             case 'WEEKLY':
  153.  
  154.                 if(empty($rrule['BYDAY']))
  155.                 return false;
  156.                     
  157.                 $days Date::byday_to_days($rrule['BYDAY']);
  158.                 $days Date::shift_days_to_local($daysdate('G'$event['start_time'])Date::get_timezone_offset($event['start_time']));
  159.  
  160.                 $interval $start_time $first_occurence_time;
  161.  
  162.                 $interval_weeks floor($interval/604800);
  163.                 $devided $interval_weeks/$event['repeat_every'];
  164.                 $rounded ceil($devided);
  165.  
  166.                 for ($i=0;$i<7;$i++)
  167.                 {
  168.                     if($i==0)
  169.                     {
  170.                         $last_occurence_time $first_occurence_time+($event['repeat_every']*$rounded*604800);
  171.                         $last_occurence_time=mktime(date('H'$first_occurence_time)date('i'$first_occurence_time),0date('m'$last_occurence_time)date('j'$last_occurence_time)-date('w'$last_occurence_time)date('Y'$last_occurence_time));
  172.                     }
  173.  
  174.                     $test_time Date::date_add($last_occurence_time$i);
  175.                     $weekday date("w"$test_time);
  176.                     //echo '*'.date('r', $start_time).' -> '.date('r', $test_time).' -> '.$event[$day_db_field[$weekday]]."\n";
  177.                     if ($days[$day_db_field[$weekday]] == '1' && $test_time>$start_time)
  178.                     {
  179.                         $occurence_time $test_time;
  180.                         break;
  181.                     }
  182.  
  183.                     if($i==&& $occurence_time<$start_time)
  184.                     {
  185.                         $rounded++;
  186.                         $i=-1;
  187.                     }
  188.                 }
  189.                 break;
  190.  
  191.             case 'DAILY':
  192.                 $interval $start_time $first_occurence_time;
  193.  
  194.                 $interval_days floor($interval/86400);
  195.                 $devided $interval_days/$event['repeat_every'];
  196.                 $rounded ceil($devided);
  197.  
  198.                 while($occurence_time<=$start_time)
  199.                 {
  200.                     $occurence_time $first_occurence_time+($event['repeat_every']*$rounded*86400);
  201.                     $occurence_time=mktime(date('H'$first_occurence_time)date('i'$first_occurence_time),0date('m'$occurence_time)date('j'$occurence_time)date('Y'$occurence_time));
  202.                     $rounded++;
  203.                 }
  204.  
  205.                 break;
  206.  
  207.             case 'MONTHLY':
  208.                 $interval_years date('Y'$start_time)-date('Y'$first_occurence_time);
  209.                 $interval_months date('n'$start_time)-date('n'$first_occurence_time);
  210.                 $interval_months 12*$interval_years+$interval_months;
  211.                     
  212.                 $devided $interval_months/$event['repeat_every'];
  213.                 $rounded ceil($devided);
  214.                 //echo '*'.$rounded."\n";
  215.  
  216.                 if (!isset($rrule['BYDAY']))
  217.                 {
  218.                     while($occurence_time<=$start_time)
  219.                     {
  220.                         $occurence_time=mktime(date('H'$first_occurence_time)date('i'$first_occurence_time),0date('n'$first_occurence_time)+($event['repeat_every']*$rounded)date('j'$first_occurence_time)date('Y'$first_occurence_time));
  221.                         $rounded++;
  222.                     }            
  223.                     
  224.                 }else
  225.                 {
  226.                     
  227.                     //Maybe more efficient to jump to right week first....
  228.  
  229.                     $event['month_time'$rrule['BYDAY'][0];
  230.                     $day substr($rrule['BYDAY']1);
  231.                         
  232.                     $days Date::byday_to_days($day);
  233.  
  234.                     if(!count($days))
  235.                     return false;
  236.  
  237.  
  238.                     $days Date::shift_days_to_local($daysdate('G'$event['start_time'])Date::get_timezone_offset($event['start_time']));
  239.  
  240.                     //debug('New call');
  241.                     ///start searching at the current day.
  242.                     $start_day=date('j'$start_time);
  243.                     $last_occurence_time=0;
  244.                     while($occurence_time==0)
  245.                     {                
  246.                         //debug('while '.$start_day.' '.$occurence_time);
  247.  
  248.                         $last_occurence_time=mktime(date('H'$first_occurence_time)date('i'$first_occurence_time),0date('n'$first_occurence_time)+($event['repeat_every']*$rounded)1date('Y'$first_occurence_time));
  249.                         $rounded++;
  250.                             
  251.                         for($d=$start_day;$d<31;$d++)
  252.                         {
  253.                             $test_time Date::date_add($last_occurence_time$d);
  254.  
  255.                             //debug('*'.date('r', $test_time));
  256.  
  257.                             $weekday date("w"$test_time);
  258.  
  259.                             if (!empty($days[$day_db_field[$weekday]]&& $test_time>$start_time && $test_time>$first_occurence_time)
  260.                             {
  261.                                 //debug('**'.ceil(date('j',$test_time)/7).' = '.$event['month_time']);
  262.                                 if (ceil(date('j',$test_time)/7== $event['month_time'])
  263.                                 {                                    
  264.                                     $occurence_time=$test_time;
  265.                                     //debug('found '.date('Ymd', $occurence_time));
  266.                                     break;
  267.                                 }
  268.                             }
  269.  
  270.                             if($d==31 && $occurence_time<$start_time)
  271.                             {
  272.                                 $rounded++;
  273.                                 $d=-1;
  274.                             }
  275.                         }
  276.                         $start_day=0;
  277.                     }
  278.                     
  279.                 }
  280.                 break;
  281.  
  282.             case 'YEARLY';
  283.             $interval_years date('Y'$start_time)-date('Y'$first_occurence_time);
  284.             $devided $interval_years/$event['repeat_every'];
  285.             $rounded ceil($devided);
  286.  
  287.             //go_log(LOG_DEBUG, $rounded);
  288.             while($occurence_time<=$start_time)
  289.             {
  290.                 $new_year date('Y'$first_occurence_time)+($event['repeat_every']*$rounded);
  291.  
  292.  
  293.  
  294.                 $occurence_time=mktime(
  295.                 date('H'$first_occurence_time),
  296.                 date('i'$first_occurence_time),
  297.                 0,
  298.                 date('n'$first_occurence_time),
  299.                 date('j'$first_occurence_time),
  300.                 $new_year);
  301.  
  302.  
  303.                 //    go_log(LOG_DEBUG, date('r', $occurence_time).' -> '.date('r', $start_time));
  304.  
  305.                 if(!$occurence_time)
  306.                 break;
  307.  
  308.                 $rounded++;
  309.             }
  310.             break;
  311.         }
  312.  
  313.  
  314.         if ($event['repeat_forever'== '0' && $occurence_time $event['repeat_end_time'])
  315.         {
  316.             return 0;
  317.         }else
  318.         {
  319.             return $occurence_time;
  320.         }
  321.  
  322.     }
  323.  
  324.  
  325.  
  326.  
  327.  
  328.     function shift_days_to_gmt($days$local_start_hour$timezone_offset)
  329.     {
  330.         $gmt_start_hour $local_start_hour-$timezone_offset;
  331.  
  332.         if ($gmt_start_hour 23{
  333.             $shift_day 1;
  334.         }elseif ($gmt_start_hour 0{
  335.             $shift_day = -1;
  336.         else {
  337.             $shift_day 0;
  338.         }
  339.  
  340.  
  341.  
  342.         if($shift_day!=0)
  343.         {
  344.             switch ($shift_day{
  345.                 case :
  346.                     $mon $days['sun'];
  347.                     $tue $days['mon'];
  348.                     $wed $days['tue'];
  349.                     $thu $days['wed'];
  350.                     $fri $days['thu'];
  351.                     $sat $days['fri'];
  352.                     $sun $days['sat'];
  353.                     break;
  354.  
  355.                 case -:
  356.                     $mon $days['tue'];
  357.                     $tue $days['wed'];
  358.                     $wed $days['thu'];
  359.                     $thu $days['fri'];
  360.                     $fri $days['sat'];
  361.                     $sat $days['sun'];
  362.                     $sun $days['mon'];
  363.                     break;
  364.             }
  365.             $days['sun']=$sun;
  366.             $days['mon']=$mon;
  367.             $days['tue']=$tue;
  368.             $days['wed']=$wed;
  369.             $days['thu']=$thu;
  370.             $days['fri']=$fri;
  371.             $days['sat']=$sat;
  372.         }
  373.         return $days;
  374.     }
  375.  
  376.  
  377.     public function shift_days_to_local($days$local_start_hour$timezone_offset)
  378.     {
  379.         //shift the selected weekdays to local time
  380.         //var_dump($days);
  381.         $gmt_start_hour $local_start_hour-$timezone_offset;
  382.  
  383.         if ($gmt_start_hour 23{
  384.             $shift_day = -1;
  385.         }elseif ($gmt_start_hour 0{
  386.             $shift_day 1;
  387.         else {
  388.             $shift_day 0;
  389.         }
  390.  
  391.         //debug($gmt_start_hour.' > '.$timezone_offset.' > '.$shift_day);
  392.  
  393.         if($shift_day!=0)
  394.         {
  395.             switch ($shift_day{
  396.                 case :
  397.                     $mon $days['sun'];
  398.                     $tue $days['mon'];
  399.                     $wed $days['tue'];
  400.                     $thu $days['wed'];
  401.                     $fri $days['thu'];
  402.                     $sat $days['fri'];
  403.                     $sun $days['sat'];
  404.                     break;
  405.  
  406.                 case -:
  407.                     $mon $days['tue'];
  408.                     $tue $days['wed'];
  409.                     $wed $days['thu'];
  410.                     $thu $days['fri'];
  411.                     $fri $days['sat'];
  412.                     $sat $days['sun'];
  413.                     $sun $days['mon'];
  414.                     break;
  415.             }
  416.  
  417.             $days['sun']=$sun;
  418.             $days['mon']=$mon;
  419.             $days['tue']=$tue;
  420.             $days['wed']=$wed;
  421.             $days['thu']=$thu;
  422.             $days['fri']=$fri;
  423.             $days['sat']=$sat;
  424.         }
  425.         return $days;
  426.     }
  427.  
  428.     /**
  429.      * Reformat a date string formatted by Group-Office user preference to a string
  430.      * that can be read by strtotime related PHP functions
  431.      *
  432.      * @param string $date_string 
  433.      * @param string $date_seperator 
  434.      * @param string $date_format 
  435.      * @return string 
  436.      */
  437.  
  438.     public static function to_input_format($date_string$date_seperator=null$date_format=null)
  439.     {
  440.         if(!isset($date_format))
  441.             $date_format=$_SESSION['GO_SESSION']['date_format'];
  442.  
  443.         if(!isset($date_seperator))
  444.             $date_seperator=$_SESSION['GO_SESSION']['date_seperator'];
  445.  
  446.         $date_string trim($date_string);
  447.         
  448.         if ($date_string != ''{
  449.  
  450.             $datetime_array explode(' '$date_string);
  451.  
  452.             $date = isset ($datetime_array[0]?
  453.             $datetime_array[0:
  454.         '0000'.$date_seperator.
  455.         '00'.$date_seperator.'00';
  456.  
  457.             $date_array explode($date_seperator$datetime_array[0]);
  458.             //$year = isset ($date_array[2]) ? $date_array[2] : date('Y');
  459.  
  460.             $format str_replace($date_seperator,'',$date_format);
  461.  
  462.             $year_pos strpos($format'Y');
  463.             $month_pos strpos($format'm');
  464.             $day_pos strpos($format'd');
  465.  
  466.             $year = isset ($date_array[$year_pos]$date_array[$year_posdate('Y');
  467.             $month = isset ($date_array[$month_pos]$date_array[$month_posdate('m');
  468.             $day = isset ($date_array[$day_pos]$date_array[$day_pos0;
  469.  
  470.             $time = isset ($datetime_array[1]$datetime_array[1'00:00';
  471.             $time_array explode(':'$time);
  472.  
  473.             $hour = isset ($time_array[0]$time_array[0'00';
  474.             $min = isset ($time_array[1]$time_array[1'00';
  475.             //$sec = isset ($time_array[2]) ? $time_array[2] : '00';
  476.  
  477.             return $year.'-'.$month.'-'.$day.' '.$hour.':'.$min;
  478.         }
  479.         return false;
  480.  
  481.     }
  482.  
  483.     /**
  484.      * Takes a date string formatted by Group-Office user preference and turns it
  485.      * into a unix timestamp.
  486.      *
  487.      * @param String $date_string 
  488.      * @return int Unix timestamp
  489.      */
  490.  
  491.  
  492.     public static function to_unixtime($date_string{
  493.         if(empty($date_string))
  494.         {
  495.             return 0;
  496.         }
  497.         $d new DateTime(Date::to_input_format($date_string));
  498.         return $d->format('U');
  499.     }
  500.  
  501.     /**
  502.      * Convert a Group-Office date to MySQL date format
  503.      *
  504.      * A Group-Office date is formated by user preference.
  505.      *
  506.      * @param    string $date_string The Group-Office date string
  507.      * @param    bool $with_time The output sting should contain time too
  508.      * @access public
  509.      * @return int unix timestamp
  510.      */
  511.  
  512.     public static function to_db_date($date_string$with_time false{
  513.         if(empty($date_string))
  514.         {
  515.             return '';
  516.         }
  517.         $time Date::to_unixtime($date_string);
  518.         $date_format $with_time 'Y-m-d H:i' 'Y-m-d';
  519.         return date($date_format$time);
  520.     }
  521.  
  522.  
  523.  
  524.     /**
  525.      * Add a period to a unix timestamp
  526.      *
  527.      * @param int $time 
  528.      * @param int $days 
  529.      * @param int $months 
  530.      * @param int $years 
  531.      * @return int 
  532.      */
  533.  
  534.  
  535.     public static function date_add($time,$days=0,$months=0,$years=0)
  536.     {
  537.         $date=getdate($time);
  538.         return mktime($date['hours'],$date['minutes']$date['seconds'],$date['mon']+$months,$date['mday']+$days,$date['year']+$years);
  539.     }
  540.  
  541.  
  542.  
  543.     /**
  544.      * Takes two Group-Office settings like Ymd and - and converts this into Y-m-d
  545.      *
  546.      * @param    string $format Any format accepted by php's date function
  547.      * @param    string $seperator A seperate like - / or .
  548.      * @access public
  549.      * @return int unix timestamp
  550.      */
  551.  
  552.     public static function get_dateformat($format$seperator)
  553.     {
  554.         $newformat '';
  555.         $end strlen($format)-1;
  556.         for($i=0;$i<$end;$i++)
  557.         {
  558.             $newformat .= $format[$i].$seperator;
  559.         }
  560.         $newformat .= $format[$i];
  561.         return $newformat;
  562.     }
  563.  
  564.  
  565.     /**
  566.      * Get the current server time in microseconds
  567.      *
  568.      * @access public
  569.      * @return int 
  570.      */
  571.     public static function getmicrotime({
  572.         list ($usec$secexplode(" "microtime());
  573.         return ((float) $usec + (float) $sec);
  574.     }
  575.  
  576.     public static function get_timestamp($utime$with_time=true$timezone='GMT')
  577.     {
  578.         if(empty($utime))
  579.         $utime=0;
  580.             
  581.         return Date::format('@'.$utime$with_time$timezone);
  582.     }
  583.  
  584.     public static function format($time$with_time=true$timezone='GMT')
  585.     {
  586.         $d new DateTime($timenew DateTimeZone($timezone));
  587.  
  588.  
  589.         if($timezone!=$_SESSION['GO_SESSION']['timezone'])
  590.         {
  591.             $tz new DateTimeZone(date_default_timezone_get());
  592.             if($tz)
  593.             {
  594.                 $d->setTimezone($tz);
  595.             }
  596.         }
  597.  
  598.         $date_format $with_time ?  $_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'$_SESSION['GO_SESSION']['date_format'];
  599.  
  600.         return $d->format($date_format);
  601.     }
  602.  
  603.     /*public static function local_to_gmt_time($utime)
  604.      {
  605.         $d = new DateTime('@'.$utime, new DateTimeZone(date_default_timezone_get()));
  606.         $d->setTimezone(new DateTimeZone('GMT'));
  607.         return $d->format('U');
  608.         }
  609.  
  610.         public static function gmt_to_local_time($utime)
  611.         {
  612.         $d = new DateTime('@'.$utime, new DateTimeZone('GMT'));
  613.         //go_log(LOG_DEBUG, date_default_timezone_get());
  614.         $d->setTimezone(new DateTimeZone(date_default_timezone_get()));
  615.         return $d->format('U');
  616.         }*/
  617.  
  618.     public static function get_timezone_offset($utime)
  619.     {
  620.         $d new DateTime('@'.$utimenew DateTimeZone(date_default_timezone_get()));
  621.         return $d->getOffset()/3600;
  622.     }
  623.  
  624.     function ical_freq_to_repeat_type($freq)
  625.     {
  626.         switch($freq)
  627.         {
  628.             case 'WEEKLY':
  629.                 return REPEAT_WEEKLY;
  630.                 break;
  631.  
  632.             case 'DAILY':
  633.                 return REPEAT_DAILY;
  634.  
  635.                 break;
  636.  
  637.             case 'MONTHLY':
  638.  
  639.                 if (!isset($rrule['BYDAY']))
  640.                 {
  641.                     return REPEAT_MONTH_DATE;
  642.                 }else
  643.                 {
  644.                     return REPEAT_MONTH_DAY;
  645.                 }
  646.                 break;
  647.  
  648.             case 'YEARLY';
  649.             return REPEAT_YEARLY;
  650.             break;
  651.  
  652.             default:
  653.                 return REPEAT_NONE;
  654.                 break;
  655.         }
  656.  
  657.     }
  658.  
  659.  
  660.     public static function build_rrule($repeat_type$interval$repeat_end_time$days$month_time)
  661.     {
  662.  
  663.         $rrule 'RRULE:';
  664.  
  665.         switch($repeat_type)
  666.         {
  667.             case REPEAT_DAILY:
  668.                 $rrule .= 'FREQ=DAILY;';
  669.                 $rrule .= 'INTERVAL='.$interval.';';
  670.                 break;
  671.  
  672.             case REPEAT_WEEKLY:
  673.  
  674.                 $event_days array();
  675.  
  676.                 if ($days['sun'== '1')
  677.                 {
  678.                     $event_days["SU";
  679.                 }
  680.                 if ($days['mon'== '1')
  681.                 {
  682.                     $event_days["MO";
  683.                 }
  684.                 if ($days['tue'== '1')
  685.                 {
  686.                     $event_days["TU";
  687.                 }
  688.                 if ($days['wed'== '1')
  689.                 {
  690.                     $event_days["WE";
  691.                 }
  692.                 if ($days['thu'== '1')
  693.                 {
  694.                     $event_days["TH";
  695.                 }
  696.                 if ($days['fri'== '1')
  697.                 {
  698.                     $event_days["FR";
  699.                 }
  700.                 if ($days['sat'== '1')
  701.                 {
  702.                     $event_days["SA";
  703.                 }
  704.  
  705.                 $rrule .= "FREQ=WEEKLY;";
  706.                 $rrule .= 'INTERVAL='.$interval.';';
  707.                 $rrule .= "BYDAY=".implode(','$event_days).';';
  708.                 break;
  709.  
  710.             case REPEAT_MONTH_DATE:
  711.                 $rrule "RRULE:FREQ=MONTHLY;";
  712.                 $rrule .= 'INTERVAL='.$interval.';';
  713.  
  714.                 break;
  715.  
  716.             case REPEAT_MONTH_DAY:
  717.  
  718.                 $event_days array();
  719.  
  720.                 if ($days['sun'== '1')
  721.                 {
  722.                     $event_days[$month_time."SU";
  723.                 }
  724.                 if ($days['mon'== '1')
  725.                 {
  726.                     $event_days[$month_time."MO";
  727.                 }
  728.                 if ($days['tue'== '1')
  729.                 {
  730.                     $event_days[$month_time."TU";
  731.                 }
  732.                 if ($days['wed'== '1')
  733.                 {
  734.                     $event_days[$month_time."WE";
  735.                 }
  736.                 if ($days['thu'== '1')
  737.                 {
  738.                     $event_days[$month_time."TH";
  739.                 }
  740.                 if ($days['fri'== '1')
  741.                 {
  742.                     $event_days[$month_time."FR";
  743.                 }
  744.                 if ($days['sat'== '1')
  745.                 {
  746.                     $event_days[$month_time."SA";
  747.                 }
  748.                     
  749.                 $rrule "RRULE:FREQ=MONTHLY;";
  750.                 $rrule .= "BYDAY=".implode(','$event_days).';';
  751.                 break;
  752.  
  753.             case REPEAT_YEARLY:
  754.                 $rrule "RRULE:FREQ=YEARLY;";
  755.                 $rrule .= 'INTERVAL='.$interval.';';
  756.                 break;
  757.         }
  758.  
  759.         if ($repeat_end_time>0)
  760.         {
  761.             $rrule .= "UNTIL=".date('Ymd'$repeat_end_time).";";
  762.         }
  763.  
  764.         return substr($rrule,0,-1);
  765.     }
  766.  
  767.  
  768.  
  769. }

Documentation generated on Thu, 30 Oct 2008 14:13:26 +0100 by phpDocumentor 1.4.0