Skip to content

Commit

Permalink
Replace pendulum with arrow + release 0.3.1 (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
DurgNomis-drol authored Aug 2, 2021
1 parent df14608 commit 4d4f686
Show file tree
Hide file tree
Showing 4 changed files with 735 additions and 767 deletions.
16 changes: 8 additions & 8 deletions mytoyota/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
import logging

import pendulum
import arrow

from .api import Controller
from .const import (
Expand Down Expand Up @@ -134,19 +134,19 @@ async def get_driving_statistics(

def calculate_from_date() -> str:
if interval == "day":
date = pendulum.now().subtract(days=1).format("YYYY-MM-DD")
date = arrow.now().shift(days=-1).format("YYYY-MM-DD")
return date

date = pendulum.now().start_of(interval).format("YYYY-MM-DD")

if date == pendulum.now().format("YYYY-MM-DD"):
if interval == "week":
date = (
pendulum.now()
.subtract(days=1)
.start_of(interval)
arrow.now()
.span("week", week_start=7)[0]
.shift(days=-1)
.format("YYYY-MM-DD")
)
return date

date = arrow.now().floor("month").shift(days=-1).format("YYYY-MM-DD")
return date

if from_date is None:
Expand Down
Loading

0 comments on commit 4d4f686

Please sign in to comment.