Monday, February 26, 2007

3599.aspx

.NET CF 2.0 Pocket Outlook DueDate problem

While porting my free Pocket PC applications to .NET CF 2.0 I just discovered an interesting "feature" of the Microsoft Pocket Outlook wrapper. The first port of poToday used my POOM wrapper for .NET CF 1.0 but I decided to drop it for the built in Microsoft PocketOutlook libraries.


My application dropped from 70kb + 30kb of wrapper DLL to only 31kb. Reorganizing the menus I am able to use the application completely without stylus which is pretty neat. But I found a problem with DueDate property that drove me crazy for a while. I can filter on the DueDate like this:


TaskCollection dueTasks = allTasks.Restrict("[DueDate] = \"" +


     System.DateTime.Today.ToString("dd/MM/yy") + "\" and [Complete]=False");


 


But as the following screenshot shows; I cannot set the DueDate to Today as it becomes yesterday:



task.DueDate should have been newDate (i.e. System.DateTime.Today) but it is 24 hours wrong :-(


I guess it converts the date to UTC link before it sets it. Whatever the reason; adding the difference between the current time and UTC works grand:


System.DateTime.Today + (System.DateTime.Now - System.DateTime.UtcNow);


 
I am still dogfooding my apps but I hope to release them soon.

1 comment:

  1. DaylightSavingTime kicked in this weekend and my fix no longer worked.



    This is, what I hope is the final, workaround for the bug:



    newDate += System.DateTime.Today - System.DateTime.Today.ToUniversalTime();

    ReplyDelete