Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetString() returns inconsistent timezones #144

Open
chris-rs opened this issue Apr 5, 2018 · 0 comments
Open

GetString() returns inconsistent timezones #144

chris-rs opened this issue Apr 5, 2018 · 0 comments

Comments

@chris-rs
Copy link

chris-rs commented Apr 5, 2018

Very handy lib when working with recurring events!

When using $rule->getString(Rule::TZ_FIXED) and DTSTART is included in the string. The string returns different timezones for UNTIL and DTSTART:
For example:
"FREQ=WEEKLY;UNTIL=20180418T220000Z;DTSTART;TZID=Europe/Amsterdam:20180405T095000;BYDAY=MO".

DTSTART is in UTC 2 and UNTIL is UTC. This seems pretty inconsistent.
When looking at Rule.php UNTIL formats to UTC and DTSTART to included timezone info.

recurr/src/Recurr/Rule.php

Lines 411 to 449 in bff55c3

// UNTIL or COUNT
$until = $this->getUntil();
$count = $this->getCount();
if (!empty($until)) {
if ($timezoneType === self::TZ_FIXED) {
$u = clone $until;
$u = $u->setTimezone(new \DateTimeZone('UTC'));
$parts[] = 'UNTIL='.$u->format($format.'\Z');
} else {
$parts[] = 'UNTIL='.$until->format($format);
}
} elseif (!empty($count)) {
$parts[] = 'COUNT='.$count;
}
// DTSTART
if ($this->isStartDateFromDtstart) {
if ($timezoneType === self::TZ_FIXED) {
$d = $this->getStartDate();
$tzid = $d->getTimezone()->getName();
$date = $d->format($format);
$parts[] = "DTSTART;TZID=$tzid:$date";
} else {
$parts[] = 'DTSTART='.$this->getStartDate()->format($format);
}
}
// DTEND
if ($this->endDate instanceof \DateTime) {
if ($timezoneType === self::TZ_FIXED) {
$d = $this->getEndDate();
$tzid = $d->getTimezone()->getName();
$date = $d->format($format);
$parts[] = "DTEND;TZID=$tzid:$date";
} else {
$parts[] = 'DTEND='.$this->getEndDate()->format($format);
}
}

Why not using same timezone, just UTC, for all date formats in the string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants