Hello,
We use the DateTimeOffset class to persist date/time values in our software. On the client (usually in a XamDataGrid) we would like to have the time displayed as a local time without the offset. To do that I used the following XAML-Code:
<igDP:Field Name="CreatedOn" Label="{l:LocText Erowa.EMC:Terms:CreatedOn}" > <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="igEditors:XamDateTimeEditor"> <Setter Property="Format" Value="G" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
Now I have a problem when the persisted DateTimeOffset values are stored with different time-offsets. It looks like the offset is simply ignored what results in wrong displayed timestamps.
What can I do to get the correct timestamps?
Regards,Martin
This is exactly what should not happen due to a control issue. It's responsibility of Infragistics to make the control compliant with MS data types. Not have the customer rewrite, add, or modify server side, client side, or backend processes to accommodate a misfire on Infragistics engineering department.
Hi Petar,
As a consequence of your answers we will change our software to use DateTime values on the client. We can easy implement the conversion to the server side used DateTimeOffset in the WCF access layer.
Once again, thank you for your help.
Hi Martin,
You can also set the UnboundField to point to the LocalDateTime or UtcDateTime properties of the DateTimeOffset class:
<igDP:UnboundField Label="Unbound DateTime" BindingPath="DateTime.LocalDateTime”…
or
<igDP:UnboundField Label="Unbound DateTime" BindingPath="DateTime.UtcDateTime" …
Please let me know if this is what you needed.
Hello Petar,
Thank you for your reply. This solution is a bit better, but it still ignores the given offset. As you may see in the sample both values have the same time but in different timezones.
What I miss now is that both time values were now displayed in the local timezone.
=> 07:27 +01:00 and 06:27 +00:00 should both be displayed as 07:27 (local timezone)
Hello Martin,
Thank you for the sample project that clarifies everything. I have been looking through it and it appears that the issue is not coming from the formatting, but rather from the inability of the XamDateTimeEditor to edit DateTimeOffset values. As you can see in the upper XamDataGrid the XamDateTimeEditor isn’t automatically set to the “DateTime” Field. If you want you can use the XamDateTimeEditor to display/edit the DateTime value of the DateTimeOffset class like so:
<igDP:UnboundField Label="Unbound DateTime" BindingPath="DateTime.DateTime" Width="150">
<igDP:Field.Settings>
<igDP:FieldSettings>
<igDP:FieldSettings.EditorStyle>
<Style TargetType="igEditors:XamDateTimeEditor">
<Setter Property="Format" Value="G" />
<Setter Property="Mask" Value="{}{date} {longtime}" />
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:UnboundField>
Please let me know, if you require any further assistance on the matter, or if I have misunderstood you in any way.