PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Easter Time Zone to UTC

Reply

Easter Time Zone to UTC

 
Thread Tools Rate Thread
Old 21-04-2004, 03:34 PM   #1
Mike
Guest
 
Posts: n/a
Default Easter Time Zone to UTC


If I have the time in New York, NY, how do I convert it to UTC? Keeping in
mind that NY uses Daylight Savings and I don't think UTC does.


  Reply With Quote
Old 21-04-2004, 03:47 PM   #2
Dick Grier
Guest
 
Posts: n/a
Default Re: Easter Time Zone to UTC

Hi,

The only way that I know of is slightly messy. I'd feed datetime (starting
with your local time - Now, in descending order, by one hour increments) to

TimeZone.CurrentTimeZone.ToLocalTime(UTCDateTime) as the UTCDateTime
argument. When the return value is the same as your local time, the
UTCDateTime is the actual UTC time.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.


  Reply With Quote
Old 21-04-2004, 03:54 PM   #3
Mike
Guest
 
Posts: n/a
Default Re: Easter Time Zone to UTC

That will convert the device time to UTC. That's not what I want to do. I
can't depend on the time on the device to be correct. I'm getting the
correct New York time and I need to set the device time to that, no matter
where the device is in the U.S.

"Dick Grier" <dick_grierNOSPAM@msn.com> wrote in message
news:uVUQL%236JEHA.2580@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> The only way that I know of is slightly messy. I'd feed datetime

(starting
> with your local time - Now, in descending order, by one hour increments)

to
>
> TimeZone.CurrentTimeZone.ToLocalTime(UTCDateTime) as the UTCDateTime
> argument. When the return value is the same as your local time, the
> UTCDateTime is the actual UTC time.
>
> Dick
>
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
> Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
>
>



  Reply With Quote
Old 21-04-2004, 04:48 PM   #4
Paul G. Tobey [eMVP]
Guest
 
Posts: n/a
Default Re: Easter Time Zone to UTC

So, you know the time in NY, but not the correct local time, the offset from
NY, or the correct GMT? It sounds like what you want to do is convert the
NY time to GMT and then use SetSystemTime() on the device. This will tell
the device, in combination with its time zone settings, what its local time
should be.

The OpenNETCF library has the necessary declarations to do much of this.
Only the conversion from NY time to GMT would have to be your
responsibility. Are you sure that you can't get the current time in GMT
instead? That's a *far* more standard time reference and you could set the
time with a single line of code:

OpenNETCF.Win32.DateTimeEx.SetSystemTime( gmt );


Paul T.

"Mike" <mikeotown@nospam.msn.com> wrote in message
news:Okri9B7JEHA.1132@TK2MSFTNGP12.phx.gbl...
> That will convert the device time to UTC. That's not what I want to do.

I
> can't depend on the time on the device to be correct. I'm getting the
> correct New York time and I need to set the device time to that, no matter
> where the device is in the U.S.
>
> "Dick Grier" <dick_grierNOSPAM@msn.com> wrote in message
> news:uVUQL%236JEHA.2580@TK2MSFTNGP12.phx.gbl...
> > Hi,
> >
> > The only way that I know of is slightly messy. I'd feed datetime

> (starting
> > with your local time - Now, in descending order, by one hour increments)

> to
> >
> > TimeZone.CurrentTimeZone.ToLocalTime(UTCDateTime) as the UTCDateTime
> > argument. When the return value is the same as your local time, the
> > UTCDateTime is the actual UTC time.
> >
> > Dick
> >
> > --
> > Richard Grier (Microsoft Visual Basic MVP)
> >
> > See www.hardandsoftware.net for contact information.
> >
> > Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
> > Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
> >
> >

>
>



  Reply With Quote
Old 21-04-2004, 06:07 PM   #5
Mike
Guest
 
Posts: n/a
Default Re: Easter Time Zone to UTC

I'm now getting the UTC time. But, yes, what I was trying to do is convert
NY time to GMT.

"Paul G. Tobey [eMVP]" <ptobey_no_spam@instrument_no_spam.com> wrote in
message news:OVVQGg7JEHA.2704@TK2MSFTNGP10.phx.gbl...
> So, you know the time in NY, but not the correct local time, the offset

from
> NY, or the correct GMT? It sounds like what you want to do is convert the
> NY time to GMT and then use SetSystemTime() on the device. This will tell
> the device, in combination with its time zone settings, what its local

time
> should be.
>
> The OpenNETCF library has the necessary declarations to do much of this.
> Only the conversion from NY time to GMT would have to be your
> responsibility. Are you sure that you can't get the current time in GMT
> instead? That's a *far* more standard time reference and you could set

the
> time with a single line of code:
>
> OpenNETCF.Win32.DateTimeEx.SetSystemTime( gmt );
>
>
> Paul T.



  Reply With Quote
Old 21-04-2004, 06:48 PM   #6
Paul G. Tobey [eMVP]
Guest
 
Posts: n/a
Default Re: Easter Time Zone to UTC

In order to do that, you need to either parse the time zone information when
the device is set to NY and then adjust the time, or you just have to know
what the offset is based on the date. There's no ConvertTimezone(
sourceTimezone, destinationTimeZone, datetime ) call...

Paul T.

"Mike" <mikeotown@nospam.msn.com> wrote in message
news:OTETwM8JEHA.2888@TK2MSFTNGP09.phx.gbl...
> I'm now getting the UTC time. But, yes, what I was trying to do is

convert
> NY time to GMT.
>
> "Paul G. Tobey [eMVP]" <ptobey_no_spam@instrument_no_spam.com> wrote in
> message news:OVVQGg7JEHA.2704@TK2MSFTNGP10.phx.gbl...
> > So, you know the time in NY, but not the correct local time, the offset

> from
> > NY, or the correct GMT? It sounds like what you want to do is convert

the
> > NY time to GMT and then use SetSystemTime() on the device. This will

tell
> > the device, in combination with its time zone settings, what its local

> time
> > should be.
> >
> > The OpenNETCF library has the necessary declarations to do much of this.
> > Only the conversion from NY time to GMT would have to be your
> > responsibility. Are you sure that you can't get the current time in GMT
> > instead? That's a *far* more standard time reference and you could set

> the
> > time with a single line of code:
> >
> > OpenNETCF.Win32.DateTimeEx.SetSystemTime( gmt );
> >
> >
> > Paul T.

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off