Skip to content

Commit

Permalink
Added __getFormattedDate function to return UTC formatted dates
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Daniel Bennett committed Sep 9, 2020
1 parent c685d35 commit 6966927
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions api/ECNQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#------------------------------------------------------------------------------#
# Imports
#------------------------------------------------------------------------------#
import os, time, email, re
import os, time, email, re, datetime
from dateutil.parser import parse
from typing import Union
import json

Expand Down Expand Up @@ -264,6 +265,22 @@ def __getAssignedTo(self) -> str:
"""
assignedTo = self.__getMostRecentHeaderByType("Assigned-To")
return assignedTo

def __getFormattedDate(self, date: str) -> str:
"""Returns the date/time recieved properly formatted.
Returns empty string if the string argument passed to the function is not a datetime
Returns:
str: Properly formatted date/time recieved or empty string.
"""
try:
objDateRecieved = parse(date)
except:
return ""

formattedDateRecieved = objDateRecieved.strftime("%Y-%m-%dT%H:%M:%S%z")

return formattedDateRecieved

def toJson(self) -> dict:
"""Returns a JSON safe representation of the item.
Expand Down Expand Up @@ -345,4 +362,4 @@ def getQueues() -> list:
if isDirectory and isValid:
queues.append(Queue(file))

return queues
return queues

0 comments on commit 6966927

Please sign in to comment.