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

fix(CalDav): add support for Microsoft time zones #49459

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SebastianKrupinski
Copy link
Contributor

@SebastianKrupinski SebastianKrupinski commented Nov 25, 2024

Summary

  • Adds handling of Microsoft time zones, when generating iMip emails
  • Corrects some spelling

Checklist

@SebastianKrupinski
Copy link
Contributor Author

/backport to stable30

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Thank you

Comment on lines +22 to +26
'AUS Central Standard Time' => 'Australia/Darwin',
'Aus Central W. Standard Time' => 'Australia/Eucla',
'AUS Eastern Standard Time' => 'Australia/Sydney',
'Afghanistan Standard Time' => 'Asia/Kabul',
'Alaskan Standard Time' => 'America/Anchorage',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the source of this list? Is it static?

if ($zone instanceof DateTimeZone) {
return $zone;
} else {
return new DateTimeZone('UTC');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about returning null here too so callers can distinguish between a successful translation and the fallback?

I think calling the method with $tz = TimeZoneFactor::fromName($foo) ?? new DateTimeZone('UTC') makes it more explicit when you actually want the fallback, and allows you to continue with null when you want to handle the failure.

*
* @return DateTimeZone
*/
public static function fromName(string $name): DateTimeZone {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be a dynamic method to allow overrides/mocks in tests?


use DateTimeZone;

class TimeZoneFactory {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@since missing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/**
* conversion table of Microsoft time zones to IANA time zones
*
* @var array $ms2iana
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @var array $ms2iana
* @var array<string, string> $ms2iana

didn't check but please make the type specific

*
* @var array $ms2iana
*/
private static $ms2iana = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this a constant

private $vCalendar2;
/** @var VCalendar */
private $vCalendar3;
private VCalendar $vCalendar1a;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: try to avoid this in bug fixes, because it may make the backport process more complicated. I suggest to either have a separate commit for refactorings, which can be left out of the backport, or do this in a separate PR

@ChristophWurst ChristophWurst added the pending documentation This pull request needs an associated documentation update label Nov 25, 2024
@ChristophWurst
Copy link
Member

Checklist

* Code is [properly formatted](https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/continuous_integration.html#linting)

* [Sign-off message](https://github.com/src-d/guide/blob/master/developer-community/fix-DCO.md) is added to all commits

*

@SebastianKrupinski please keep the original PR template from https://github.com/nextcloud/server/blob/master/.github/pull_request_template.md. Writing docs is very relevant here. Don't drop this.

/**
* Determines if given time zone name is a Microsoft time zone
*
* @since Release 31.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @since Release 31.0.0
* @since 31.0.0

same for the rest of the file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews backport-request pending documentation This pull request needs an associated documentation update
Projects
Status: 🏗️ In progress
Development

Successfully merging this pull request may close these issues.

2 participants