🔍 Code Extractor

class TimeZoneInformation

Maturity: 50

A data class representing time zone information with support for Windows and IANA (Olson) time zone formats.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/timezone_information.py
Lines:
4 - 18
Complexity:
simple

Purpose

TimeZoneInformation is a value object that encapsulates time zone data for use in Office 365 API operations. It inherits from ClientValue, making it suitable for serialization and transmission in API requests. The class stores a time zone identifier (alias) and a human-readable display name, providing a standardized way to represent time zones across different systems.

Source Code

class TimeZoneInformation(ClientValue):
    """Represents a time zone. The supported format is Windows, and Internet Assigned Numbers Authority (IANA)
    time zone (also known as Olson time zone) format as well when the current known problem is fixed.
    """

    def __init__(self, alias=None, display_name=None):
        """
        :param str alias: An identifier for the time zone.
        :param str display_name: A display string that represents the time zone.
        """
        self.alias = alias
        self.displayName = display_name

    def __repr__(self):
        return self.displayName

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

alias: An identifier string for the time zone. This can be in Windows time zone format (e.g., 'Pacific Standard Time') or IANA/Olson format (e.g., 'America/Los_Angeles'). Optional parameter that defaults to None if not provided.

display_name: A human-readable string that represents the time zone for display purposes (e.g., '(UTC-08:00) Pacific Time (US & Canada)'). Optional parameter that defaults to None if not provided.

Return Value

Instantiation returns a TimeZoneInformation object with the specified alias and display_name attributes. The __repr__ method returns the display_name string when the object is printed or converted to a string representation.

Class Interface

Methods

__init__(self, alias=None, display_name=None)

Purpose: Constructor that initializes a TimeZoneInformation instance with optional alias and display name

Parameters:

  • alias: Optional string identifier for the time zone in Windows or IANA format
  • display_name: Optional human-readable string representing the time zone

Returns: None (constructor)

__repr__(self) -> str

Purpose: Returns a string representation of the TimeZoneInformation object for debugging and display purposes

Returns: The displayName attribute value as a string. Returns None if displayName is not set.

Attributes

Name Type Description Scope
alias str or None An identifier for the time zone in Windows format (e.g., 'Pacific Standard Time') or IANA/Olson format (e.g., 'America/Los_Angeles') instance
displayName str or None A human-readable display string that represents the time zone, typically including UTC offset and location (e.g., '(UTC-08:00) Pacific Time (US & Canada)') instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue

Usage Example

from office365.runtime.client_value import ClientValue

class TimeZoneInformation(ClientValue):
    def __init__(self, alias=None, display_name=None):
        self.alias = alias
        self.displayName = display_name
    
    def __repr__(self):
        return self.displayName

# Create a time zone for Pacific Standard Time
pst_timezone = TimeZoneInformation(
    alias='Pacific Standard Time',
    display_name='(UTC-08:00) Pacific Time (US & Canada)'
)

# Create a time zone using IANA format
la_timezone = TimeZoneInformation(
    alias='America/Los_Angeles',
    display_name='Los Angeles Time'
)

# Access attributes
print(pst_timezone.alias)  # 'Pacific Standard Time'
print(pst_timezone.displayName)  # '(UTC-08:00) Pacific Time (US & Canada)'
print(pst_timezone)  # Prints: (UTC-08:00) Pacific Time (US & Canada)

# Create with minimal information
utc_timezone = TimeZoneInformation(alias='UTC')
print(utc_timezone.alias)  # 'UTC'
print(utc_timezone.displayName)  # None

Best Practices

  • Always provide both alias and display_name when creating instances for better clarity and user experience
  • Use Windows time zone format for compatibility with Office 365 services (e.g., 'Pacific Standard Time', 'Eastern Standard Time')
  • IANA/Olson format support may have limitations as mentioned in the docstring - verify compatibility with your specific Office 365 API version
  • The class is immutable by design - attributes should be set during initialization rather than modified after creation
  • This class inherits from ClientValue, which means it's designed for serialization in Office 365 API requests - don't add complex objects as attributes
  • The __repr__ method returns displayName, so ensure displayName is set if you need meaningful string representations
  • This is a data transfer object (DTO) - it has no business logic and should only store time zone information

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class TimeZoneInformation_v1 83.5% similar

    A data class that represents time zone information including bias values for standard time, daylight saving time, and UTC offset.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/webs/time_zone_information.py
  • class TimeZoneBase 73.8% similar

    A basic representation of a time zone that extends ClientValue, storing and displaying time zone names.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/timezones/base.py
  • class DateTimeTimeZone 72.4% similar

    A class representing a date, time, and time zone combination for a specific point in time, compatible with Office 365 API structures.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/dateTimeTimeZone.py
  • class TimeZone 64.1% similar

    Represents a SharePoint time zone setting, providing methods to convert between local time and UTC, and access time zone metadata.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/webs/time_zone.py
  • class LocaleInfo 62.5% similar

    A data class representing locale information for a signed-in user, including their preferred language and country/region settings.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/locale_info.py
← Back to Browse