Skip to content

Commit 146fadd

Browse files
committed
openshift: Add a helper function to parse the datetime for the template.
1 parent aee1de8 commit 146fadd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

zulip/integrations/openshift/zulip_openshift_config.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# https://github.com/python/mypy/issues/1141
2+
from datetime import datetime
23
from typing import Dict, Optional
34

5+
import zulip
6+
47
# Change these values to configure authentication for the plugin
58
ZULIP_USER = "[email protected]"
69
ZULIP_API_KEY = "0123456789abcdef0123456789abcdef"
@@ -28,6 +31,14 @@ def deployment_notice_destination(branch: str) -> Optional[Dict[str, str]]:
2831
return None
2932

3033

34+
# To utilize Zulip's global times (https://zulip.com/help/global-times)
35+
# call this function from format_deployment_message, and use the
36+
# returned string in your message template.
37+
def get_global_time(dt_str: str) -> str:
38+
dt = datetime.strptime(dt_str, "%Y-%m-%d %H:%M:%S %z")
39+
return zulip.datetime_to_global_time(dt)
40+
41+
3142
# Modify this function to change how deployments are displayed
3243
#
3344
# It takes the following arguments:
@@ -39,9 +50,6 @@ def deployment_notice_destination(branch: str) -> Optional[Dict[str, str]]:
3950
# * commit_id = hash of the commit that triggered the deployment
4051
# * dep_id = deployment id
4152
# * dep_time = deployment timestamp
42-
#
43-
# To utilize Zulip's global times (https://zulip.com/help/global-times),
44-
# use the syntax `<time:dep_time>`.
4553
def format_deployment_message(
4654
app_name: str = "",
4755
url: str = "",

0 commit comments

Comments
 (0)