byteclubfr / todotxt

Todo.txt parser/serializer for node
ISC License
6 stars 4 forks source link

Tests fail if you're west of UTC because local date != UTC date #2

Open evanp opened 6 years ago

evanp commented 6 years ago

There's a mixing of dates in the code and test suite between "local" and "UTC" dates, which is probably fine if you're east of Greenwich, and which causes errors if you're not.

This command will give passing tests:

TZ=Europe/Paris npm test

This command will give failing tests:

TZ=America/New_York npm test

I think the proper handling should be to use the user's local timezone for all dates, since that's what people probably mean when they set a date in their todo.txt file.

It might be nice to add a way for parse(), stringify() and item() to take a separate timezone argument, so if you're doing development where the user's timezone isn't the same as the system timezone (say, for a Web application), you can pass the user's timezone in. I'll add that as another issue.