blob: 73f08f905ec9b3b716a1c7f687829e19ae82ee16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import pathlib
import datetime
from serenitas.utils.env import DAILY_DIR
def get_dir(workdate: datetime.date, archived=True) -> pathlib.Path:
p = DAILY_DIR / str(workdate) / "Reports"
if not p.exists() and archived:
p = (
DAILY_DIR
/ str(workdate.year)
/ f"{workdate:%Y_%m}"
/ str(workdate)
/ "Reports"
)
return p
def dt_from_fname(f, dt_format="%Y%m%d%H%M"):
return datetime.datetime.strptime(
f.name.removesuffix(".csv").removesuffix(".xlsx").rsplit("_")[-1], dt_format
)
|