class TimeZoneInformation
A data class representing time zone information with support for Windows and IANA (Olson) time zone formats.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/timezone_information.py
4 - 18
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 formatdisplay_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
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class TimeZoneInformation_v1 83.5% similar
-
class TimeZoneBase 73.8% similar
-
class DateTimeTimeZone 72.4% similar
-
class TimeZone 64.1% similar
-
class LocaleInfo 62.5% similar