NMF-earth / nmf-app

Understand and reduce your carbon footprint 🌱 iOS & Android.
https://nmf.earth
GNU General Public License v3.0
498 stars 156 forks source link

update emissionslist to use utc and fixed tests #210

Closed adamfitzgibbon closed 3 years ago

adamfitzgibbon commented 3 years ago

Addresses #205

I couldn't find a good way to set jest to UTC in a way that worked with windows, but I dug deeper and realized it was only relevant for the EmissionsList tests. It took me a while to track down where the offending code was, because the test seemed to be always using utc when passing dates around. Turns out that groupBy function news up a new moment object with the time passed in which was causing it to tack on the timezone even though it just wants a start of the month date.

This change could possibly affect how the emissions are displayed to users if they created it right on the start or end of a month and their timezone pushes it across the edge since it would be using the utc date instead of their local date. Let me know if you have any suggestions here. There might be a way to chop off the timezone information after the start of month is evaluated (calling utc after the fact adjusted the time value of the date)

PierreBresson commented 3 years ago

I think tests shouldn't drive the dev and change the reality of the data, so for now let's not merge it. Very annoying situation I agree and unfortunately I don't have any solution since I'm on macos.