rcastberg / sure_petcare

Python library for accessing sure connect petflap
GNU General Public License v3.0
55 stars 15 forks source link

Make the cache timestamp tz-aware, Increment cache version #9

Closed therefromhere closed 5 years ago

therefromhere commented 5 years ago

For consistency with the SurePet api data, and so that the cachefile doesn't depend on machine timezone.

Note that this is a breaking change (will cause a TypeError vs existing caches due to naive vs aware comparison). Is that a problem? - if so I could either handle the TypeError, or bump the cache version and make update_required check the version?

rcastberg commented 5 years ago

I think it would be nice to handle this change in a sensible manor. Cleanest i guess would be looking into the cache version.

therefromhere commented 5 years ago

OK, I'll take a look at the cache version.

strix-technica commented 5 years ago

@therefromhere As a matter of best practice, timestamps should always be stored as UTC. Admittedly, it's unlikely that you'll move between geographic timezones frequently, but it's still worth doing if only to avoid twice-annual confusion when clocks change with daylight savings.

therefromhere commented 5 years ago

Yeah, currently the cache timestamp is using naive machine time, my change will make it use a aware UTC .

therefromhere commented 5 years ago

I've updated that now so cache is reset except for the auth token when the version changes.

So ./sp_cli.py --update should work through a version change.