mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-24 17:36:39 +00:00
Pull the freebusy floating-time handling into a function
This commit is contained in:
parent
28c78023b5
commit
5fc3875345
@ -305,6 +305,18 @@ class RepeatRuleDateTime extends DateTime {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function withFallbackTzid( $date, $fallback_tzid ) {
|
||||
// Floating times or dates (either VALUE=DATE or with no TZID) can default to the collection's tzid, if one is set
|
||||
|
||||
if ($date->GetParameterValue('VALUE') == 'DATE' && isset($fallback_tzid)) {
|
||||
return new RepeatRuleDateTime($date->Value()."T000000", new RepeatRuleTimeZone($fallback_tzid));
|
||||
} else if ($date->GetParameterValue('TZID') === null && isset($fallback_tzid)) {
|
||||
return new RepeatRuleDateTime($date->Value(), new RepeatRuleTimeZone($fallback_tzid));
|
||||
} else {
|
||||
return new RepeatRuleDateTime($date);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function __toString() {
|
||||
return (string)parent::format(self::$Format) . ' ' . parent::getTimeZone()->getName();
|
||||
|
||||
@ -66,13 +66,7 @@ function get_freebusy( $path_match, $range_start, $range_end, $bin_privs = null
|
||||
}
|
||||
|
||||
// Floating dtstarts (either VALUE=DATE or with no TZID) can default to the collection's tzid, if one is set
|
||||
if ($start_date->GetParameterValue('VALUE') == 'DATE' && isset($collection_tzid)) {
|
||||
$start_date = new RepeatRuleDateTime($start_date->Value()."T000000", new RepeatRuleTimeZone($collection_tzid));
|
||||
} else if ($start_date->GetParameterValue('TZID') === null && isset($collection_tzid)) {
|
||||
$start_date = new RepeatRuleDateTime($start_date->Value(), new RepeatRuleTimeZone($collection_tzid));
|
||||
} else {
|
||||
$start_date = new RepeatRuleDateTime($start_date);
|
||||
}
|
||||
$start_date = RepeatRuleDateTime::withFallbackTzid( $start_date, $collection_tzid );
|
||||
|
||||
$duration = $v->GetProperty('DURATION');
|
||||
$duration = ( !isset($duration) ? 'P1D' : $duration->Value());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user