.NET Framework - Setting Date/Time for daylight savings using Opennetcf Ver 2.0

Asked By ManishBafn on 19-Jan-08 04:53 AM
I am using opennetcf.windowsce namespace of Smart Device Framework 2.0 for
daylight savings.I was able to successfully
set timezone using SetTimeZoneInformation but i am not able to set Date/Time
using LocalTime and SystemTime of DatetimeHelper.I am not able to figure out
how to set bias/offset using LocalTime and SystemTime for daylight savings.I
would be grateful if somebody could provide complete working code for setting
date/time(with bias/offset) for daylight savings.
Any help would be highly appreciated.As it is urgent i would appreciate if
somebody can provide complete working code.
Thanks in advance for replying(as always)




Freesc replied on 19-Jan-08 01:11 PM
On Jan 19, 5:53=A0pm, Manish Bafna

me
ut
.I
ing


hi~

i'm not using OpenNetCF but p/Invoke,this is the code that works

[DllImport("Coredll.dll", SetLastError=3Dtrue)]
public static extern bool SetLocalTime(ref SystemTime
lpSystemTime);

public struct SystemTime
{
public short wYear;
public short wMonth;
public short wDayOfWeek;
public short wDay;
public short wHour;
public short wMinute;
public short wSecond;
public short wMilliseconds;
}

public void SetTime()
{

SystemTime systNew =3D new SystemTime();
SystemTime gtsystNew =3D new SystemTime();

systNew.wDay =3D 10;
systNew.wMonth =3D 8;
systNew.wYear =3D 2007;
systNew.wHour =3D 1;
systNew.wMinute =3D 0;
systNew.wSecond =3D 0;

SetLocalTime(ref systNew);
}
Paul G. Tobey [eMVP] replied on 21-Jan-08 11:30 AM
You don't set a bias or offset when you set the time; you just set the time.
If you call SetLocalTime(), that's the time, plain and simple.  Doesn't care
what time zone is set or anything else; it's simply the time (it's like
setting the time on your watch).  If you call SetSystemTime(), that's
setting GMT (or whatever you want to call it), so the time zone is used to
figure out what the local time actually is.  *That* is then set.

Paul T.