-
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 7dc87c2
Showing
3 changed files
with
38 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
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") | ||
def convertToDateTime(x: str) -> datetime: | ||
dt = datetime.strptime(x, "%Y-%m-%dT%H:%M:%SZ") | ||
return dt.replace(tzinfo=utc) | ||
|
||
def format_date(dt: datetime) -> str: | ||
return dt.astimezone(localtz).strftime("%Y-%m-%d %H:%M:%S") | ||
|
||
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) |