-
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
UTC issue #1
Comments
Hi @pgolebiowski, This is strange, but according to the documentation we shouldn't pass the Please let me know if I'm wrong. |
Hi @olsh, First, thank you for your continuous effort on providing the library. Much appreciated! 😄 Here is my code: var client = new TodoistClient("here is my token");
var item1 = new Item("Test item with date string.")
{
DateString = "2017-12-01"
};
var item2 = new Item("Test item with UTC DateTime.")
{
DueDateUtc = new DateTime(2017, 12, 1, 0, 0, 0, DateTimeKind.Utc)
};
var id1 = client.Items.AddAsync(item1).Result;
var id2 = client.Items.AddAsync(item2).Result;
var retrieved1 = client.Items.GetAsync(id1).Result.Item.DueDateUtc.Value;
var retrieved2 = client.Items.GetAsync(id2).Result.Item.DueDateUtc.Value;
Console.WriteLine(retrieved1.ToString("u"));
Console.WriteLine(retrieved2.ToString("u")); The result:
I understand -- Todoist converts dates to the local time instead of just showing what was assigned there. It totally makes sense. However, the result is exactly the same when I change When I type: var item = new Item("Test item with UTC DateTime.")
{
DueDateUtc = new DateTime(2017, 12, 1, 0, 0, 0, DateTimeKind.Local).ToUniversalTime()
};
var id = client.Items.AddAsync(item).Result;
var retrieved = client.Items.GetAsync(id).Result.Item.DueDateUtc.Value;
Console.WriteLine(retrieved.ToString("u")); Then it works:
Hope it helps. |
Ahh, I see the problem now. |
Thank you for the detail explanation! 👍 |
@olsh Glad to help. Keep up the great work! 😄 |
Regarding the property
Item.DueDateUtc
, it does not seem to be in UTC when sent to Todoist. Here is your code for the converter:I think it is missing
Z
at the end: https://www.w3.org/TR/NOTE-datetime.Even though I specifically assign a
DateTime
that hasDateTimeKind
set toUtc
andhour=0
andminutes=0
, it gets converted to01:00
, because theUtcDateTimeConverter
does not specify UTC (missingZ
).The text was updated successfully, but these errors were encountered: