Skip to content

Commit

Permalink
Merge pull request #107 from kunmosky1/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
MtkN1 committed Jan 2, 2022
2 parents 16299d9 + 1333fc2 commit 551f2f6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
29 changes: 28 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion pybotters/models/gmocoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import logging
from datetime import datetime, timezone
from dateutil import parser
from decimal import Decimal
from enum import Enum, auto
from typing import Any, Awaitable, Optional, cast
Expand All @@ -23,7 +24,21 @@

def parse_datetime(x: Any) -> datetime:
if isinstance(x, str):
return datetime.strptime(x, "%Y-%m-%dT%H:%M:%S.%f%z")
try:
exec_date = x.replace('T', ' ')[:-1]
exec_date = exec_date + '00000000'
dt = datetime(
int(exec_date[0:4]),
int(exec_date[5:7]),
int(exec_date[8:10]),
int(exec_date[11:13]),
int(exec_date[14:16]),
int(exec_date[17:19]),
int(exec_date[20:26]),
)
except Exception:
dt = parser.parse(x)
return dt
else:
raise ValueError(f'x only support str, but {type(x)} passed.')

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ python = "^3.7"
aiohttp = "^3.7.4"
rich = "^10.1.0"
typing-extensions = "^3.10.0"
python-dateutil = "^2.8.2"

[tool.poetry.dev-dependencies]
pytest = "^6.2.3"
Expand Down

0 comments on commit 551f2f6

Please sign in to comment.