[coldfusion] Add automation (#172)
Co-authored-by: Marc Wrobel <marc.wrobel@gmail.com>
This commit is contained in:
@@ -3,8 +3,6 @@ import calendar
|
||||
|
||||
|
||||
def parse_date(text, formats=frozenset([
|
||||
"%B %d, %Y", # January 1, 2020
|
||||
"%b %d, %Y", # Jan 1, 2020
|
||||
"%B %d %Y", # January 1 2020
|
||||
"%b %d %Y", # Jan 1 2020
|
||||
"%d %B %Y", # 1 January 2020
|
||||
@@ -33,13 +31,14 @@ def parse_datetime(text, formats=frozenset([
|
||||
"%Y-%m-%d %H:%M:%S", # 2023-05-01 08:32:34
|
||||
"%Y-%m-%dT%H:%M:%S", # 2023-05-01T08:32:34
|
||||
"%Y-%m-%d %H:%M:%S %z", # 2023-05-01 08:32:34 +0900
|
||||
"%a, %d %b %Y %H:%M:%S %Z", # Wed, 01 Jan 2020 00:00:00 GMT
|
||||
"%a %d %b %Y %H:%M:%S %Z", # Wed, 01 Jan 2020 00:00:00 GMT
|
||||
"%Y-%m-%dT%H:%M:%S%z", # 2023-05-01T08:32:34+0900
|
||||
]), to_utc=True) -> datetime:
|
||||
"""Parse a given text representing a datetime using a list of formats,
|
||||
optionally converting it to UTC.
|
||||
"""
|
||||
text = text.strip()
|
||||
text = text.replace(", ", " ") # so that we don't have to deal with commas in formats
|
||||
for fmt in formats:
|
||||
try:
|
||||
date = datetime.strptime(text, fmt)
|
||||
|
||||
Reference in New Issue
Block a user