diff --git a/convert_time.py b/convert_time.py new file mode 100644 index 00000000000..59f561313ff --- /dev/null +++ b/convert_time.py @@ -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)) diff --git a/slack_message.py b/slack_message.py index 7eecf9ebb9c..e0c346718a0 100644 --- a/slack_message.py +++ b/slack_message.py @@ -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) - ) \ No newline at end of file +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) +# ) \ No newline at end of file