Skip to content

Instantly share code, notes, and snippets.

@ichux
Created June 1, 2024 12:53
Show Gist options
  • Save ichux/44cd1ae3dc0e5b210b61a73f59fc7644 to your computer and use it in GitHub Desktop.
Save ichux/44cd1ae3dc0e5b210b61a73f59fc7644 to your computer and use it in GitHub Desktop.
from datetime import datetime
import pytz
data = {
"sub": [
["a1", "2024-07-01 07:39:41 UTC+0000"],
["a3", "2024-07-01 07:39:41 UTC+0000"],
["j5", "2024-07-01 07:39:41 UTC+0000"],
]
}
valid = []
current_time = datetime.now(pytz.UTC)
for username, date in data["sub"]:
representation = datetime.strptime(date, "%Y-%m-%d %H:%M:%S %Z%z")
if current_time <= representation.astimezone(pytz.UTC):
valid.append(username)
print(valid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment