mirror of
https://github.com/b4tman/sync_ics2gcal
synced 2025-02-01 20:28:30 +00:00
fix parsing config start_from
(#82)
This commit is contained in:
parent
70a9dac822
commit
839a3ac0c3
@ -1,4 +1,4 @@
|
|||||||
from typing import Dict, Any
|
from typing import Dict, Any, Union
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
@ -13,6 +13,8 @@ from . import (
|
|||||||
CalendarSync
|
CalendarSync
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ConfigDate = Union[str, datetime.datetime]
|
||||||
|
|
||||||
|
|
||||||
def load_config() -> Dict[str, Any]:
|
def load_config() -> Dict[str, Any]:
|
||||||
with open('config.yml', 'r', encoding='utf-8') as f:
|
with open('config.yml', 'r', encoding='utf-8') as f:
|
||||||
@ -20,11 +22,13 @@ def load_config() -> Dict[str, Any]:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def get_start_date(date_str: str) -> datetime.datetime:
|
def get_start_date(date: ConfigDate) -> datetime.datetime:
|
||||||
if 'now' == date_str:
|
if isinstance(date, datetime.datetime):
|
||||||
|
return date
|
||||||
|
if 'now' == date:
|
||||||
result = datetime.datetime.utcnow()
|
result = datetime.datetime.utcnow()
|
||||||
else:
|
else:
|
||||||
result = dateutil.parser.parse(date_str)
|
result = dateutil.parser.parse(date)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user