Skip to content

Commit fddaab4

Browse files
Add in timezone property for timepicker element (#1251)
1 parent 2965fa1 commit fddaab4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

slack_sdk/models/blocks/block_elements.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class TimePickerElement(InputInteractiveElement):
461461

462462
@property
463463
def attributes(self) -> Set[str]:
464-
return super().attributes.union({"initial_time"})
464+
return super().attributes.union({"initial_time", "timezone"})
465465

466466
def __init__(
467467
self,
@@ -471,6 +471,7 @@ def __init__(
471471
initial_time: Optional[str] = None,
472472
confirm: Optional[Union[dict, ConfirmObject]] = None,
473473
focus_on_load: Optional[bool] = None,
474+
timezone: Optional[str] = None,
474475
**others: dict,
475476
):
476477
"""
@@ -494,6 +495,7 @@ def __init__(
494495
that appears after a time is selected.
495496
focus_on_load: Indicates whether the element will be set to auto focus within the view object.
496497
Only one element can be set to true. Defaults to false.
498+
timezone: The timezone to consider for this input value.
497499
"""
498500
super().__init__(
499501
type=self.type,
@@ -505,6 +507,7 @@ def __init__(
505507
show_unknown_key_warning(self, others)
506508

507509
self.initial_time = initial_time
510+
self.timezone = timezone
508511

509512
@JsonValidator("initial_time attribute must be in format 'HH:mm'")
510513
def _validate_initial_time_valid(self) -> bool:

tests/slack_sdk/models/test_elements.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,19 @@ def test_focus_on_load(self):
382382
}
383383
self.assertDictEqual(input, TimePickerElement(**input).to_dict())
384384

385+
def test_timezone(self):
386+
input = {
387+
"type": "timepicker",
388+
"action_id": "timepicker123",
389+
"initial_time": "11:40",
390+
"placeholder": {
391+
"type": "plain_text",
392+
"text": "Select a time",
393+
},
394+
"timezone": "America/Los_Angeles",
395+
}
396+
self.assertDictEqual(input, TimePickerElement(**input).to_dict())
397+
385398

386399
# -------------------------------------------------
387400
# Image

0 commit comments

Comments
 (0)