-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b02e5f
commit eefc642
Showing
6 changed files
with
52 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,26 @@ | ||
from datetime import datetime, timedelta | ||
import pytz | ||
from os import environ | ||
|
||
convertToDateTime = lambda x: datetime.strptime(x, "%Y-%m-%dT%H:%M:%SZ") | ||
utc = pytz.utc | ||
localtz = pytz.timezone(environ["TIMEZONE"]) | ||
|
||
format_date = lambda x: x.strftime("%Y-%m-%d %H:%M:%S") | ||
get_now = lambda :datetime.now(utc) | ||
|
||
def convertToDateTime(x: str) -> datetime: | ||
dt = datetime.strptime(x, "%Y-%m-%dT%H:%M:%SZ") | ||
return dt.replace(tzinfo=utc) | ||
|
||
def format_local(dt: datetime) -> str: | ||
return dt.astimezone(localtz).strftime("%Y-%m-%d %H:%M:%S") | ||
|
||
def format_to_utc(dt: datetime) -> str: | ||
return dt.astimezone(utc).strftime("%Y-%m-%dT%H:%M:%SZ") | ||
|
||
def trim_and_format(x: str) -> str: | ||
if len(x) > 200: | ||
x = x[:200] + "..." | ||
return ">" + x.strip().replace("\n", "\n> ") | ||
|
||
def get_n_day_prior(n: int) -> datetime: | ||
return datetime.now() - timedelta(days=n) | ||
return datetime.now(utc) - timedelta(days=n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ charset-normalizer==3.1.0 | |
idna==3.4 | ||
requests==2.28.2 | ||
urllib3==1.26.15 | ||
pytz==2023.3 |