Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions convert_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Created by sarathkaul on 12/11/19


def convert_time(input_str):
# Checking if last two elements of time
# is AM and first two elements are 12
if input_str[-2:] == "AM" and input_str[:2] == "12":
return "00" + input_str[2:-2]

# remove the AM
elif input_str[-2:] == "AM":
return input_str[:-2]

# Checking if last two elements of time
# is PM and first two elements are 12
elif input_str[-2:] == "PM" and input_str[:2] == "12":
return input_str[:-2]

else:
# add 12 to hours and remove PM
return str(int(input_str[:2]) + 12) + input_str[2:8]


if __name__ == '__main__':
input_time = str(raw_input("Enter time you want to convert: "))
print(convert_time(input_time))
15 changes: 8 additions & 7 deletions slack_message.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Created by sarathkaul on 11/11/19

import json
import requests
import urllib.request

# Set the webhook_url to the one provided by Slack when you create the webhook at https://my.slack.com/services/new/incoming-webhook/
webhook_url = 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
slack_data = {'text': "Hi Sarath Kaul"}

response = requests.post(webhook_url, data=json.dumps(slack_data),headers={'Content-Type': 'application/json'})
if response.status_code != 200:
raise ValueError(
'Request to slack returned an error %s, the response is:\n%s'
% (response.status_code, response.text)
)
response = urllib.request.Request(webhook_url, data=json.dumps(slack_data),headers={'Content-Type': 'application/json'})
print response
# if response.status_code != 200:
# raise ValueError(
# 'Request to slack returned an error %s, the response is:\n%s'
# % (response.status_code, response.text)
# )