Enable more debugging so I can see timezone differences in CI

This commit is contained in:
Andrew Ruthven 2021-09-18 22:15:27 +12:00
parent 9d520ab56d
commit 19e69060b9
2 changed files with 23 additions and 10 deletions

View File

@ -41,6 +41,7 @@ test:
when:
always
script:
- date
- apt-get -y update
- bash -c 'mkdir -p /usr/share/man/man{0..10}'
- apt-get -y install locales

View File

@ -30,8 +30,8 @@ function olson_from_vtimezone( vComponent $vtz ) {
return null;
}
// define( 'DEBUG_RRULE', true);
define( 'DEBUG_RRULE', false );
define( 'DEBUG_RRULE', true);
// define( 'DEBUG_RRULE', false );
/**
* Wrap the DateTimeZone class to allow parsing some iCalendar TZID strangenesses
@ -280,23 +280,28 @@ class RepeatRuleDateTime extends DateTime {
}
elseif ( $dtz === null || $dtz == '' ) {
$dtz = self::$UTCzone;
if ( preg_match('/(\d{8}(T\d{6})?)(Z?)/', $date, $matches) ) {
if ( preg_match('/(\d{8}(T\d{6})?) ?(.*)$/', $date, $matches) ) {
$date = $matches[1];
$this->tzid = ( $matches[3] == 'Z' ? 'UTC' : null );
if ( $matches[3] == 'Z' ) {
$this->tzid = 'UTC';
} else {
$dtz = new RepeatRuleTimeZone($matches[3]);
$this->tzid = $dtz->tzid();
}
}
$this->is_date = (strlen($date) == 8 );
if ( DEBUG_RRULE ) printf( "Date%s value with timezone: %s in %s\n", ($this->is_date?"":"Time"), $date, $this->tzid );
if ( DEBUG_RRULE ) printf( "Date%s value with timezone 1: %s in %s\n", ($this->is_date?"":"Time"), $date, $this->tzid );
}
elseif ( is_string($dtz) ) {
$dtz = new RepeatRuleTimeZone($dtz);
$this->tzid = $dtz->tzid();
$type = gettype($date);
if ( DEBUG_RRULE ) printf( "Date%s $type with timezone: %s in %s\n", ($this->is_date?"":"Time"), $date, $this->tzid );
if ( DEBUG_RRULE ) printf( "Date%s $type with timezone 2: %s in %s\n", ($this->is_date?"":"Time"), $date, $this->tzid );
}
else {
$this->tzid = $dtz->getName();
$type = gettype($date);
if ( DEBUG_RRULE ) printf( "Date%s $type with timezone: %s in %s\n", ($this->is_date?"":"Time"), $date, $this->tzid );
if ( DEBUG_RRULE ) printf( "Date%s $type with timezone 3: %s in %s\n", ($this->is_date?"":"Time"), $date, $this->tzid );
}
parent::__construct($date, $dtz);
@ -636,7 +641,7 @@ class RepeatRule {
$this->original_rule = $rrule;
if ( DEBUG_RRULE ) {
printf( "Constructing RRULE based on: '%s', rrule: '%s' (we float: %s)\n", $basedate, $rrule, ($return_floating_times?"yes":"no") );
printf( "Constructing RRULE based on: '%s', rrule: '%s' (float: %s)\n", $basedate, $rrule, ($return_floating_times ? "yes" : "no") );
}
if ( preg_match('{FREQ=([A-Z]+)(;|$)}', $rrule, $m) ) $this->freq = $m[1];
@ -674,7 +679,7 @@ class RepeatRule {
/** need to handle the error, but FREQ is mandatory so unlikely */
}
$this->frequency_string = sprintf('+%d %s', $this->interval, $this->freq_name );
if ( DEBUG_RRULE ) printf( "Frequency modify string is: '%s', base is: '%s'\n", $this->frequency_string, $this->base->format('c') );
if ( DEBUG_RRULE ) printf( "Frequency modify string is: '%s', base is: '%s', TZ: %s\n", $this->frequency_string, $this->base->format('c'), $this->base->getTimeZone() );
$this->Start($return_floating_times);
}
@ -738,6 +743,13 @@ class RepeatRule {
public function valid() {
if ( DEBUG_RRULE && isset($this->instances[$this->position])) {
$current = $this->instances[$this->position];
print "TimeZone: " . $current->getTimeZone() . "\n";
print "Date: " . $current->format('r') . "\n";
print "Errors:\n";
print_r($current->getLastErrors());
}
if ( isset($this->instances[$this->position]) || !$this->finished ) return true;
return false;
}
@ -793,7 +805,7 @@ class RepeatRule {
$this->current_base->modify( $this->frequency_string );
}
if ( $return_floating_times ) $this->current_base->setAsFloat();
if ( DEBUG_RRULE ) printf( "Getting more instances from: '%s' - %d\n", $this->current_base->format('c'), count($this->instances) );
if ( DEBUG_RRULE ) printf( "Getting more instances from: '%s' - %d, TZ: %s\n", $this->current_base->format('c'), count($this->instances), $this->current_base->getTimeZone() );
$this->current_set = array( clone($this->current_base) );
foreach( self::rrule_expand_limit($this->freq) AS $bytype => $action ) {
if ( isset($this->{$bytype}) ) {