Changeset 7579


Ignore:
Timestamp:
11/29/12 17:12:33 (11 years ago)
Author:
acoutinho
Message:

Ticket #3233 - Problemas na configuracao da hora de um evento.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoCalendar/setup/setup.inc.php

    r7164 r7579  
    1313        $setup_info['expressoCalendar']['title']        = 'Expresso Calendar'; 
    1414        /* Ao incrementar versão, não esquecer de declarar função do tables_update.inc.php*/ 
    15         $setup_info['expressoCalendar']['version']      = '1.009'; 
     15        $setup_info['expressoCalendar']['version']      = '1.011'; 
    1616        $setup_info['expressoCalendar']['app_order']    = 10; 
    1717 
  • trunk/expressoCalendar/setup/tables_current.inc.php

    r7378 r7579  
    248248                'frequency' => array(  'type' => 'varchar','precision' => '20', 'nullable' => False), 
    249249                'until' => array(  'type' => 'int', 'precision' => '8', 'nullable' => True), 
    250                 'dtstart' => array(  'type' => 'bigint','precision' => '16', 'nullable' => True), 
     250                        'dtstart' => array(  'type' => 'bigint','precision' => '16', 'nullable' => True), 
    251251                'count' => array(  'type' => 'int', 'precision' => '8', 'nullable' => True), 
    252252                'object_id' => array(  'type' => 'int', 'precision' => '8', 'nullable' => False), 
     
    261261                'bysetpos' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
    262262                'wkst' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
    263                 'exceptions' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
     263                        'exceptions' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
    264264                'interval' => array(  'type' => 'int', 'precision' => '8', 'nullable' => True) 
    265265            ), 
     
    334334            'uc' => array() 
    335335                ), 
     336 
     337 
     338        'calendar_timezones' => array( 
     339            'fd' => array( 
     340                'id' => array( 'type' => 'auto', 'nullable' => False), 
     341                'timezone' => array(  'type' => 'varchar','precision' => '150', 'nullable' => False), 
     342 
     343                'standard_frequency' => array(  'type' => 'varchar','precision' => '20', 'nullable' => False), 
     344                'standard_dtstart' => array(  'type' => 'varchar','precision' => '20', 'nullable' => True), 
     345                'standard_byday' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
     346                'standard_bymonth' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
     347                'standard_from' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True), 
     348                'standard_to' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True), 
     349 
     350                'daylight_frequency' => array(  'type' => 'varchar','precision' => '20', 'nullable' => False), 
     351                'daylight_dtstart' => array(  'type' => 'varchar','precision' => '20', 'nullable' => True), 
     352                'daylight_byday' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
     353                'daylight_bymonth' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
     354                'daylight_from' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True), 
     355                'daylight_to' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True), 
     356 
     357                'dtstamp' => array( 'type' => 'bigint', 'precision' => '16', 'precision' => '16', 'nullable' => False) 
     358            ), 
     359            'pk' => array('id'), 
     360            'fk' => array(), 
     361            'ix' => array(), 
     362            'uc' => array() 
     363        ), 
    336364                 
    337365        ); 
  • trunk/expressoCalendar/setup/tables_update.inc.php

    r7378 r7579  
    191191        return $GLOBALS['setup_info']['expressoCalendar']['currentver']; 
    192192    }; 
     193 
     194 
     195    $test[] = '1.010'; 
     196    function expressoCalendar_upgrade1_010() { 
     197        $oProc = $GLOBALS['phpgw_setup']->oProc; 
     198 
     199 
     200            $oProc->CreateTable('calendar_timezones', array( 
     201                'fd' => array( 
     202                    'id' => array( 'type' => 'auto', 'nullable' => False), 
     203                    'timezone' => array(  'type' => 'varchar','precision' => '150', 'nullable' => False), 
     204 
     205                    'standard_frequency' => array(  'type' => 'varchar','precision' => '20', 'nullable' => False), 
     206                    'standard_dtstart' => array(  'type' => 'varchar','precision' => '20', 'nullable' => True), 
     207                    'standard_byday' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
     208                    'standard_bymonth' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
     209                    'standard_from' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True), 
     210                    'standard_to' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True), 
     211 
     212                    'daylight_frequency' => array(  'type' => 'varchar','precision' => '20', 'nullable' => False), 
     213                    'daylight_dtstart' => array(  'type' => 'varchar','precision' => '20', 'nullable' => True), 
     214                    'daylight_byday' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
     215                    'daylight_bymonth' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
     216                    'daylight_from' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True), 
     217                    'daylight_to' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True), 
     218 
     219                    'dtstamp' => array( 'type' => 'bigint', 'precision' => '16', 'precision' => '16', 'nullable' => False) 
     220                ), 
     221                'pk' => array('id'), 
     222                'fk' => array(), 
     223                'ix' => array(), 
     224                'uc' => array() 
     225            ) 
     226        ); 
     227 
     228        $oProc->query("INSERT INTO calendar_timezones(timezone, standard_frequency, standard_dtstart, standard_byday, 
     229        standard_bymonth, standard_from, standard_to, daylight_frequency, daylight_dtstart, daylight_byday, 
     230        daylight_bymonth, daylight_from, daylight_to, dtstamp) VALUES ('America/Sao_Paulo', 'YEARLY', '23:59', 
     231        '4SA', '2', '-0200','-0300', 'YEARLY', '23:59', '3SA', '10', '-0300','-0200', '". time() ."');"); 
     232 
     233        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.011'; 
     234        return $GLOBALS['setup_info']['expressoCalendar']['currentver']; 
     235    }; 
    193236         
    194237?> 
  • trunk/prototype/modules/calendar/interceptors/DBMapping.php

    r7519 r7579  
    9393 
    9494    static function parseTimeDate($time, $timezone) { 
    95         return strtotime($time . ' ' . $timezone) . '000'; 
     95            return strtotime($time . ' ' . $timezone) . '000'; 
    9696    } 
    9797 
     
    822822    //TODO: Remover apos suporte a deepness na api  
    823823    public function deepnessFindEvent(&$uri, &$result, &$criteria, $original) { 
    824         if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) { 
    825             $Time = new DateTime('now', new DateTimeZone('UTC')); 
    826             $DayLigth = array(); 
    827             foreach ($result as $i => $v) { 
    828  
    829                 if ( isset($v['calendar']) && (!isset($currentTimezone) || $currentTimezone != $original['criteria']['timezones'][$v['calendar']]))  { 
    830                     $currentTimezone = isset($original['criteria']['timezones'][$v['calendar']]) ? $original['criteria']['timezones'][$v['calendar']] : $v['timezone']; 
    831                     $Time->setTimezone(new DateTimeZone($currentTimezone)); 
    832                 } 
    833  
    834                 $Time->setTimestamp((int) ($v['startTime'] / 1000)); 
    835                 $DayLigth['calendar']['startTime'] = $Time->format('I') ? 1 : 0; 
    836  
    837                 $Time->setTimestamp((int) ($v['endTime'] / 1000)); 
    838                 $DayLigth['calendar']['endTime'] = $Time->format('I') ? 1 : 0; 
    839  
    840                 if (!isset($currentTimezone) || ($currentTimezone != $v['timezone'])) { 
    841                     $currentTimezone = $v['timezone']; 
    842                     $Time->setTimezone(new DateTimeZone($v['timezone'])); 
    843  
    844                     $Time->setTimestamp((int) ($v['startTime'] / 1000)); 
    845                     $DayLigth['event']['startTime'] = $Time->format('I') ? 1 : 0; 
    846  
    847                     $Time->setTimestamp((int) ($v['endTime'] / 1000)); 
    848                     $DayLigth['event']['endTime'] = $Time->format('I') ? 1 : 0; 
    849                 }else 
    850                     $DayLigth['event'] = $DayLigth['calendar']; 
    851  
    852  
    853                 $result[$i]['DayLigth'] = $DayLigth; 
    854  
    855         if(((int)$v['type']) == 2){ 
    856  
    857             $taskToActivity = Controller::find(array('concept' => 'taskToActivity'), false, array('filter' => array('AND', array('=', 'activity', $v['id']), array('=','owner', Config::me('uidNumber'))) , 'deepness' => 2)); 
    858  
    859             if($taskToActivity) 
    860                 $result[$i]['taskToActivity'] = $taskToActivity; 
    861  
    862             $result[$i]['historic'] = Controller::find(array('concept' => 'calendarHistoric'), false, array('filter' => array('=', 'schedulable', $v['id']) , 'deepness' => 2)); 
    863  
     824        if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) { 
     825 
     826            $date = new DateTime('now', new DateTimeZone('UTC')); 
     827            $DayLigth = array(); 
     828 
     829            foreach ($result as $i => $v) { 
     830 
     831                $currentTimezone = isset($original['criteria']['timezones'][$v['calendar']]) ? $original['criteria']['timezones'][$v['calendar']] : $v['timezone']; 
     832 
     833                $date->setTimestamp((int) ($v['startTime'] / 1000)); 
     834                $date->setTimezone( new DateTimeZone( $v['timezone'] )); 
     835                $DayLigth['event']['startTime'] = ($date->getTimestamp() + $date->getOffset()).'000'; 
     836 
     837                $date->setTimezone( new DateTimeZone($currentTimezone)); 
     838                $DayLigth['calendar']['startTime'] = ($date->getTimestamp() + $date->getOffset()).'000'; 
     839 
     840                $date->setTimestamp((int) ($v['endTime'] / 1000)); 
     841                $date->setTimezone( new DateTimeZone($currentTimezone)); 
     842                $DayLigth['event']['endTime'] = ($date->getTimestamp() + $date->getOffset()).'000'; 
     843 
     844                $date->setTimezone( new DateTimeZone($currentTimezone)); 
     845                $DayLigth['calendar']['endTime'] = ($date->getTimestamp() + $date->getOffset()).'000'; 
     846 
     847 
     848                $result[$i]['DayLigth'] = $DayLigth; 
     849 
     850                if(((int)$v['type']) == 2){ 
     851 
     852                    $taskToActivity = Controller::find(array('concept' => 'taskToActivity'), false, array('filter' => array('AND', array('=', 'activity', $v['id']), array('=','owner', Config::me('uidNumber'))) , 'deepness' => 2)); 
     853 
     854                    if($taskToActivity) 
     855                        $result[$i]['taskToActivity'] = $taskToActivity; 
     856 
     857                    $result[$i]['historic'] = Controller::find(array('concept' => 'calendarHistoric'), false, array('filter' => array('=', 'schedulable', $v['id']) , 'deepness' => 2)); 
     858 
     859                } 
     860 
     861                if (isset($v['id'])) { 
     862                    $data = self::decodeParticipantsEvent($uri, $v, $criteria, $original); 
     863 
     864                    $result[$i]['statusAttendees'] = isset($data['statusAttendees']) ? $data['statusAttendees'] : false; 
     865                    $result[$i]['sizeAttendees'] = isset($data['sizeAttendees']) ? $data['sizeAttendees'] : false; 
     866                    $result[$i]['participants'] = $data['attendees']; 
     867 
     868                    $attachmentRelation = Controller::find(array('concept' => 'schedulableToAttachment'), false, array('filter' => array('=', 'schedulable', $v['id']))); 
     869                    if (is_array($attachmentRelation)) { 
     870                    $attachments = array(); 
     871                    foreach ($attachmentRelation as $key => $value) 
     872                        if (isset($value['attachment']) || !!$value['attachment']) 
     873                        $attachments[$key] = $value['attachment']; 
     874                    //Pega os anexos sem source 
     875                    $result[$i]['attachments'] = Controller::find(array('concept' => 'attachment'), array('id', 'name', 'type', 'size'), array('filter' => array('IN', 'id', $attachments))); 
     876                    } 
     877 
     878                    $repeat = Controller::find(array('concept' => 'repeat'), false, array('filter' => array('=', 'schedulable', $v['id']))); 
     879 
     880                    unset($result[$i]['repeat']); 
     881 
     882                    if (is_array($repeat)) 
     883                    $result[$i]['repeat'] = $repeat[0]; 
     884                } 
     885            } 
    864886        } 
    865887 
    866                 if (isset($v['id'])) { 
    867                     $data = self::decodeParticipantsEvent($uri, $v, $criteria, $original); 
    868  
    869                     $result[$i]['statusAttendees'] = isset($data['statusAttendees']) ? $data['statusAttendees'] : false; 
    870                     $result[$i]['sizeAttendees'] = isset($data['sizeAttendees']) ? $data['sizeAttendees'] : false; 
    871                     $result[$i]['participants'] = $data['attendees']; 
    872  
    873                     $attachmentRelation = Controller::find(array('concept' => 'schedulableToAttachment'), false, array('filter' => array('=', 'schedulable', $v['id']))); 
    874                     if (is_array($attachmentRelation)) { 
    875                         $attachments = array(); 
    876                         foreach ($attachmentRelation as $key => $value) 
    877                             if (isset($value['attachment']) || !!$value['attachment']) 
    878                                 $attachments[$key] = $value['attachment']; 
    879                         //Pega os anexos sem source 
    880                         $result[$i]['attachments'] = Controller::find(array('concept' => 'attachment'), array('id', 'name', 'type', 'size'), array('filter' => array('IN', 'id', $attachments))); 
    881                     } 
    882  
    883                     $repeat = Controller::find(array('concept' => 'repeat'), false, array('filter' => array('=', 'schedulable', $v['id']))); 
    884  
    885                     unset($result[$i]['repeat']); 
    886  
    887                     if (is_array($repeat)) 
    888                         $result[$i]['repeat'] = $repeat[0]; 
    889                 } 
    890             } 
    891         } 
    892  
    893         return $result; 
     888        return $result; 
     889    } 
     890 
     891    public function diffOffset( $from, $to ){ 
     892 
     893        if(($from < 0 && $to < 0) || ($from > 0 && $to > 0) ){ 
     894 
     895            return ($from - $to); 
     896 
     897        }else{ 
     898            return ( $from > 0 ? ($to - $from) : ($from - $to)); 
     899        } 
     900 
    894901    } 
    895902     
     
    11751182            $uri['id'] = $idSchedulable; 
    11761183 
    1177  
    11781184            if(isset($criteria['type']) && $criteria['type'] == '2'){ 
    11791185 
  • trunk/prototype/modules/calendar/js/calendar.codecs.js

    r7397 r7579  
    605605                timezone: objEvent.timezone, 
    606606                timezones: Timezone.timezones, 
    607                 startDate: new Date( parseInt(objEvent.startTime) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ), 
    608                 startHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.startTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat), 
    609                 endDate: new Date( parseInt(objEvent.endTime) - (!!parseInt(objEvent.allDay) ? 86400000 : 0)  ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ), 
    610                 endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(objEvent.endTime)),  objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'endTime'), User.preferences.hourFormat), 
     607                startDate: Timezone.getDate( (objEvent.DayLigth ? objEvent.DayLigth.event.startTime : objEvent.startTime), 'start', objEvent.allDay ), 
     608        startHour: objEvent.DayLigth ? Timezone.getHour( objEvent.DayLigth.event.startTime) : Timezone.formateHour( objEvent.startTime ), 
     609        endDate: Timezone.getDate( (objEvent.DayLigth ? objEvent.DayLigth.event.endTime : objEvent.endTime), 'end', objEvent.allDay ), 
     610                endHour: objEvent.DayLigth ? Timezone.getHour( objEvent.DayLigth.event.endTime) : Timezone.formateHour( objEvent.endTime ), 
    611611                allDay: !!parseInt( objEvent.allDay ), 
    612612                dueDate: objEvent.dueDate, 
     
    14071407                            isExternal: !!parseInt(form.attendeeType[i]) ? 1 : 0, 
    14081408                            acl: form.attendee_organizer == attendee ? (form.attendeeAcl[i].indexOf('o') < 0 ? form.attendeeAcl[i]+'o' : form.attendeeAcl[i]) : form.attendeeAcl[i].replace('o', '') 
    1409                         }, form.delegatedFrom[i] != '0' ? { 
     1409                        }, (form.delegatedFrom[i] != '0' && form.delegatedFrom[i] != '') ? { 
    14101410                            delegatedFrom: form.delegatedFrom[i] 
    14111411                            } : {}); 
     
    17471747            } 
    17481748 
    1749                 var duration = parseInt( evt.endTime ) - parseInt( evt.startTime ), isRepeat = false; 
     1749                var duration = parseInt( evt.DayLigth.calendar.endTime ) - parseInt( evt.DayLigth.calendar.startTime ), isRepeat = false; 
    17501750 
    17511751                var occurrences = []; 
     
    17561756                        occurrences = evt.occurrences; 
    17571757            }else 
    1758                         occurrences[ occurrences.length ] = evt.startTime; 
     1758                        occurrences[ occurrences.length ] = evt.DayLigth.calendar.startTime; 
    17591759 
    17601760            //occurrences = DataLayer.unique( occurrences ).sort(); 
     
    17671767                                id: evt.URI || evt.id+ '-' + i, 
    17681768                                title: Encoder.htmlDecode(evt.summary), 
    1769                                 start: Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) ), calendar.timezone,  !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving), 
    1770                                 end:   Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) + duration - (!!parseInt(evt.allDay) ? 86400000 : 0)), calendar.timezone, !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving), 
     1769                                start: Timezone.getDateObjCalendar( occurrences[i], 'start', evt.allDay), 
     1770                end: Timezone.getDateObjCalendar( (parseInt( occurrences[i] ) + duration), 'end', evt.allDay), 
    17711771                                allDay: parseInt( evt.allDay ), 
    17721772                                isRepeat: isRepeat, 
  • trunk/prototype/modules/calendar/js/init.js

    r7524 r7579  
    349349                }, 
    350350 
    351                 eventRender: function( event, element, view ){ 
     351 
     352        eventRender: function( event, element, view ){ 
    352353                    $('#calendar td.fc-year-have-event').removeClass('fc-year-have-event'); 
    353354 
     
    363364            element.find(".fc-event-inner.fc-event-skin").prepend($('<img style="width: 11px; height: 13px;" class="" src="../prototype/modules/calendar/img/' + img_icon + '"></img>')); 
    364365                }, 
    365                  
     366 
    366367                select: function( start, end, allDay, event, view ){ 
    367368                        if (view.name == "month") { 
     
    502503                 
    503504                eventAfterRender: function(event, element, view){ 
     505 
    504506                        contentMenu(); 
     507 
    505508                } 
    506509        }, dateCalendar));       
  • trunk/prototype/modules/calendar/js/timezone.js

    r6069 r7579  
    55*/ 
    66 
    7 var objTime = DataLayer.dispatch( "timezones" ); 
     7var objTime = DataLayer.dispatch( "timezones", {teste:'123'} ); 
    88 
    99Timezone = { 
     
    1111        daylightSaving: isNaN(parseInt( objTime.isDaylightSaving )) ? 0 : parseInt( objTime.isDaylightSaving ), 
    1212 
     13    start:false, 
     14    end:false, 
     15 
    1316        timezones: objTime.timezones,      
    14         timezone: function( tzId ){ 
     17 
     18    timezone: function( tzId ){ 
    1519 
    1620                return this.timezones[ tzId || User.preferences.timezone ]; 
     
    1822        }, 
    1923         
    20         getDateCalendar: function(date, tzId, isDay){ 
    21                 var timezone = this.timezone( tzId ); 
     24        getDateCalendar: function( date, tzId, isDayLigth ){ 
    2225 
    23                 if(!timezone) 
    24                         return date; 
     26        return date; 
    2527 
    26                 date = this.normalizeDate(date, false, true); 
    27  
    28                 return date.add({hours: parseInt(timezone.charAt(0) + timezone.charAt(2))  +  parseInt(isDay) }); 
    2928        }, 
    3029         
    31         getDateEvent: function(date, tzId, idCalendar, isDay, type){ 
    32                 var timezone = this.timezone( tzId ); 
    33                 var timezoneCurrent = this.timezone(DataLayer.get('calendar', idCalendar).timezone); 
     30        getDateEvent: function(date, tzId, isDayLigth){ 
     31        if(!tzId) 
     32            return date; 
    3433 
    35                 if(timezone == timezoneCurrent) 
    36                         return date; 
    37                  
    38                 var to = parseInt(timezone.charAt(0) + timezone.charAt(2)) + parseInt(isDay.event[type]); 
    39                 var current = parseInt(timezoneCurrent.charAt(0) + timezoneCurrent.charAt(2)) + parseInt(isDay.calendar[type]); 
    40                  
    41                 if(timezone.charAt(0) == timezoneCurrent.charAt(0)) 
    42                         hours =   (  to + (current * - 1)) ; 
    43                 else 
    44                         hours =  to + (( current ) * (timezone.charAt(0) ==  '+'  ? -1 : 1)) ; 
    45                  
    46                 return date.add({hours: hours}); 
     34        var timezone = this.timezone( tzId ); 
     35 
     36        if(!timezone) 
     37            return date; 
     38 
     39        date = this.normalizeDate(date, false, true); 
     40 
     41        return date.add({hours: (parseInt(timezone.charAt(0) + timezone.charAt(2)) + Timezone.diff( isDayLigth )) }); 
    4742        }, 
    48          
     43 
     44    diff: function(isDayLigth){ 
     45 
     46        if( !parseInt( isDayLigth ) ){ 
     47            return 0; 
     48        }else{ 
     49 
     50            return (parseInt( isDayLigth ) == 1 ? 1 : -1); 
     51        } 
     52 
     53    }, 
     54 
    4955        normalizeDate: function(date, current, inverse){ 
     56 
    5057                var offsetDate = !!current ? this.currentOffset : date.getUTCOffset(); 
    5158                return date.add({hours: (parseInt(offsetDate.charAt(0) + offsetDate.charAt(2)) * (!!inverse ? -1 : 1) )}); 
     59 
    5260        }, 
    5361         
    5462        getDateMapDisponibility: function(date){ 
     63 
    5564                return this.normalizeDate(date, false, true); 
    56         } 
     65 
     66        }, 
     67 
     68    getHour: function(time){ 
     69 
     70        return dateCalendar.formatDate( Timezone.normalizeDate( new Date( parseInt( time ) ), false, true) , User.preferences.hourFormat); 
     71 
     72    }, 
     73 
     74    formateHour: function(time){ 
     75 
     76        return dateCalendar.formatDate(  new Date( parseInt( time ) ) , User.preferences.hourFormat); 
     77 
     78    }, 
     79 
     80    getDate: function( time, rang, isAllDay){ 
     81 
     82        return (new Date( parseInt( time ) - ((rang == 'end' && isAllDay && parseInt(isAllDay) == 1) ? 86400000 : 0) )).toString( User.preferences.dateFormat ); 
     83 
     84    }, 
     85 
     86    getDateObj: function( time, rang, isAllDay){ 
     87 
     88        return Timezone.normalizeDate(new Date( parseInt( time ) - ((rang == 'end' && isAllDay && parseInt(isAllDay) == 1) ? 86400000 : 0) ), false, true); 
     89 
     90    }, 
     91 
     92    getDateObjCalendar: function( time, rang, isAllDay){ 
     93 
     94        return  Timezone.normalizeDate(new Date( parseInt( time ) - ((rang == 'end' && isAllDay && parseInt(isAllDay) == 1) ? 86400000 : 0)), false, true); 
     95 
     96    } 
     97 
     98 
    5799} 
  • trunk/prototype/services/iCal.php

    r7243 r7579  
    111111                                        $this->createAttachment($v['attachments'], $vevent); 
    112112 
    113                             $vevent->setProperty('uid', $v['uid']);   
     113                            $vevent->setProperty('uid', $v['uid']); 
     114 
     115                $timezoneDayligth = Controller::read(array('concept' => 'timezones'), null, array('filter' => array('=', 'tzid', $apTimezone))); 
     116 
     117                if(!empty( $timezoneDayligth ) && count( $timezoneDayligth ) > 0){ 
     118 
     119                    if(array_key_exists(0, $timezoneDayligth)) 
     120                        $timezoneDayligth = $timezoneDayligth[0]; 
     121 
     122                    date_default_timezone_set('UTC'); 
     123 
     124                    require_once ROOTPATH . '/plugins/when/When.php'; 
     125 
     126                    $r = new When(); 
     127 
     128                    $start = new DateTime('1970-01-01 '.$timezoneDayligth['standardDtstart']); 
     129 
     130                    $r = new When(); 
     131                    $r->recur($start, $timezoneDayligth['standardFrequency']) 
     132                        ->until($start->modify('+1 years')) 
     133                        ->bymonth(array( $timezoneDayligth['standardBymonth'] )) 
     134                        ->byday(array(  $timezoneDayligth['daylightByday'] )); 
     135 
     136                   $date = $r->next(); 
     137 
     138                    $timezone = &$ical->newComponent('vtimezone'); 
     139                    $timezone->setProperty('tzid',$apTimezone ); 
     140 
     141                    $standard  = &$timezone->newComponent( "standard" ); 
     142                    $standard->setProperty( "tzoffsetfrom", $timezoneDayligth['standardFrom'] ); 
     143                    $standard->setProperty( "tzoffsetto", $timezoneDayligth['standardTo'] ); 
     144 
     145 
     146                    $standard->setProperty( "dtstart", $date->format(DATE_RFC822), array("VALUE" => "DATE") ); 
     147 
     148                    $rrule = array( 
     149                        'FREQ' => $timezoneDayligth['standardFrequency'], 
     150                        'BYMONTH' =>  $timezoneDayligth['standardBymonth'], 
     151                        'BYday' => array(preg_replace("/[^0-9]/", "", $timezoneDayligth['standardByday']),  "DAY" => preg_replace("/[^a-zA-Z\s]/", "", $timezoneDayligth['standardByday'])) 
     152                    ); 
     153 
     154                    $standard->setProperty('rrule', $rrule); 
     155 
     156                    $daylight  = &$timezone->newComponent( "daylight" ); 
     157 
     158                    $daylight->setProperty( "tzoffsetfrom", $timezoneDayligth['daylightFrom'] ); 
     159                    $daylight->setProperty( "tzoffsetto", $timezoneDayligth['daylightTo'] ); 
     160 
     161 
     162                    $start = new DateTime('1970-01-01 '.$timezoneDayligth['daylightDtstart']); 
     163 
     164                    $r->recur($start, $timezoneDayligth['daylightFrequency']) 
     165                        ->until($start->modify('+1 years')) 
     166                        ->bymonth(array( $timezoneDayligth['daylightBymonth'] )) 
     167                        ->byday(array(  $timezoneDayligth['daylightByday'] )); 
     168 
     169                    $date = $r->next(); 
     170 
     171                    $daylight->setProperty( "dtstart", $date->format(DATE_RFC822), array("VALUE" => "DATE") ); 
     172 
     173                    $rrule = array( 
     174                        'FREQ' => $timezoneDayligth['daylightFrequency'], 
     175                        'BYMONTH' =>  $timezoneDayligth['daylightBymonth'], 
     176                        'BYday' => array(preg_replace("/[^0-9]/", "", $timezoneDayligth['daylightByday']),  "DAY" => preg_replace("/[^a-zA-Z\s]/", "", $timezoneDayligth['daylightByday'])) 
     177                    ); 
     178 
     179                    $daylight->setProperty('rrule', $rrule); 
     180                } 
     181 
    114182                            break; 
    115183            case TODO_ID: 
     
    352420                foreach ($pRepeat as $ir => $rv) { 
    353421                    if ($rv) { 
    354                         if ($ir == 'frequency' && $rv !== 'none') 
    355                             $repeat['FREQ'] = $rv; 
    356                         else if ($ir == 'endTime') { 
    357                             $time = new DateTime('@' . (int) ($rv / 1000), new DateTimeZone('UTC')); 
    358                             $time->setTimezone($apTimezoneOBJ); 
    359                             $repeat['until'] = $time->format(DATE_RFC822); 
    360                         } else if ($ir == 'count') 
    361                             $repeat[$ir] = $rv; 
    362                         else if ($ir == 'interval') 
    363                             $repeat[$ir] = $rv; 
    364                         else if ($ir !== 'schedulable' && $ir !== 'id' && $ir !== 'startTime') 
    365                             $repeat[$ir] = explode(',', $rv); 
     422                if ($ir == 'frequency' && $rv !== 'none') 
     423                    $repeat['FREQ'] = $rv; 
     424                else if ($ir == 'endTime') { 
     425                    $time = new DateTime('@' . (int) ($rv / 1000), new DateTimeZone('UTC')); 
     426                    $time->setTimezone($apTimezoneOBJ); 
     427                    $repeat['until'] = $time->format(DATE_RFC822); 
     428                }else if ($ir == 'count') 
     429                    $repeat[$ir] = $rv; 
     430                else if ($ir == 'interval') 
     431                    $repeat[$ir] = $rv; 
     432                else if ($ir !== 'schedulable' && $ir !== 'id' && $ir !== 'startTime') 
     433                    $repeat[$ir] = explode(',', $rv); 
    366434                    } 
    367435                } 
  • trunk/prototype/timezones.php

    r7036 r7579  
    1212 
    1313$localtime = localtime(time(), true); 
    14 $timezone['isDaylightSaving'] =  !!$localtime['tm_isdst']; 
     14$timezone['isDaylightSaving'] =  !!$localtime['tm_isdst'] ? 1 : 0; 
    1515 
    1616echo json_encode($timezone); 
Note: See TracChangeset for help on using the changeset viewer.