From c58761cbd93755e0dd190f903fd2a88ca9e0d370 Mon Sep 17 00:00:00 2001 From: vidyasree4045 <55986973+vidyasree4045@users.noreply.github.com> Date: Mon, 5 Oct 2020 15:07:59 +0530 Subject: [PATCH] Create Parsing_string.py --- parsing_string.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 parsing_string.py diff --git a/parsing_string.py b/parsing_string.py new file mode 100644 index 000000000..17a006247 --- /dev/null +++ b/parsing_string.py @@ -0,0 +1,16 @@ +import re +import time + +from cgi import parse_header +from collections import OrderedDict +@@ -44,9 +43,7 @@ +def _parse_datetime_header(value): + match = re.match(r'^(?P.*?)(?P[+-]\d{4})?$', value) + + tt = time.strptime(match.group('datetime'), '%Y-%m-%d %H:%M') + ts = time.mktime(tt) + dt = datetime.fromtimestamp(ts) + dt = datetime.strptime(match.group('datetime'), '%Y-%m-%d %H:%M') + + # Separate the offset into a sign component, hours, and # minutes + tzoffset = match.group('tzoffset')