-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reopen "Fix DueDate.StringDate conversion to and from DateTime." #41
Conversation
The class is used to change the time zone of the tests upon initialization, and resets it back when disposed.
The added tests ensure consistency in StringDate property setter and getter.
Date is now converted using the round-trip format without milliseconds. Date is also no longer being converted to universal time before formatting.
DateTimeKind is switched to Unspecified instead of Utc since the due date should be treated as floating.
@olsh For example, when a user's code tries to create a floating due date with a local So, should we prevent |
I'll take a look at the problem deeper. BTW, here is the related issue |
The fix reverts back to depending on `DueDate.Timezone` property to determine the conversion formatting. However, it doesn't convert the `DueDate.Date` value to universal time unless the `DueDate` is intended to be fixed.
Timezone info was missing for a fixed date.
Since floating due dates are now converted to `Unspecified` date time, the method `ToLocalTime` is no longer used because it assumes the given date as `UTC`.
@olsh First of all, for floating due dates, we ignore any timezone info given in the
That is because floating dates only represent a time in the user's timezone, no matter where he is:
So, the code makes sure that whatever date is given should be the same date we find in the task without conversion. Second, for fixed due dates, we should provide time in UTC since all timezone info is stored in
That's why any dates given with the kind
Conversion of local Commits with these changes have been added, only one simple extra change is made to the failing test:
Since floating due dates are now converted to I hope this approach solves the problem. |
@AhmedZaki99 thank you for the contribution. These changes totally make sense to me.
With only necessary parameters. I think the API is more explicit and easy to understand. Also, it's worth adding comments to the methods from the Todoist docs. Because the due date concept is pretty hard to understand. |
@olsh Great suggestion! Should I create another pull request for it or should I just add the commits here? |
Let's add the changes to this PR. |
Methods include detailed documentation comments.
Static methods that are used to instantiate DueDates are now in charge of handling different kinds of dates.
Three commits are added:
|
P.S. Don't forget to run all tests, I am not sure what might break after all these changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! Let's do the last changes and merge the PR.
Fake time zone random selection is replaced by pre-determined custom offset.
Kudos, SonarCloud Quality Gate passed!
|
Thank you! 👍🏻 |
Fixes #36
All previous details of this request are discussed in #37
While I was checking this failing test, I noticed that the
Roundtrip
date conversion depends on information about timezones given in theDueDate.Date
object itself, however, Todoist API always treats theDueDate.Date
object as a UTC date and depends on theDueDate.Timezone
to store timezone info.I will try to fix this issue and update the pull request with a new commit shortly.