blob: 318bb4eb231ea1f42785d6c224d557fb037900da (
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):
return datetime.datetime.strptime(
f.name.removesuffix(".csv").removesuffix(".xlsx").rsplit("_")[-1], "%Y%m%d%H%M"
)
|