Pedro Rosas Silva wrote:
> On Dec 2, 4:32 pm, "Armin Zingler" <az.nos...@freenet.de> wrote:
>> Pedro Rosas Silva wrote:
>>> Hello Everyone,
>>
>>> I want to build/use a control that allows the user to select a UTC
>>> datetime.
>>> As far as I am concerned, DateTimePicker allows the user to select a
>>> datetime based on the local culture settings.
>>> Is it possible to change this and force the selection to be done in
>>> UTC datetime instead of the local culture settings?
>>> How could it be done?
>>> Please advice if you have any idea.
>>> Thanks in advance.
>>
>> I don't think so. Though, you can easily reinterpret it:
>>
>> Dim ValueUTC = DateTime.SpecifyKind(DTP.value, DateTimeKind.Utc)
>>
>> Or, you can store it in a DateTimeOffset object:
>>
>> Dim DTO = New DateTimeOffset(ValueUTC)
>>
>> Interesting IMO:http://msdn.microsoft.com/en-us/library/bb384267.aspx
>>
>> Also be aware that there's still a bug showing the 'Kind' value in
>> the immediate window or using the tooltip (at least in VB 2008).
>> (http://connect.microsoft.com/VisualS...Feedback.aspx?...)
>>
>> Armin
>
>
> Thank you Armin.
> I used the SpecifyKind method and I managed to solve my problem.
>
> But, anyway, there is a intersting "feature?" in the 'DateTimePicker'
> control.
> Whenever you try to change its 'DateTime' property,
You mean the Value property.?
> the 'Kind'
> property is lost.
> It seems that the 'Kind' property is inherited and is always set to
> 'Unspecified':
>
> http://drowningintechnicaldebt.com/b...d-setting.aspx
I guess it's not what you described but it's the IDE bug I've described in
my first post: Displaying the value is buggy, not the assignment to the
value. Try this:
Dim dt = Now
MsgBox(dt.Kind.ToString)
DateTimePicker1.Value = dt
dt = DateTimePicker1.Value
MsgBox(dt.Kind.ToString)
I get "Local" twice. Though, evaluating dt.kind during debugging, it always
displays 'Unspecified'. Have a look at the link I posted.
Armin