M
MDB
Hello all, I am having problems with SetSystemTime. For some reason, my
ppc2003 device is not adjusting for DST (time behind by one hour). Here is
how I am setting it with the UTC time being passed to the function, should I
be doing this differently?
[DllImport("coredll.dll")]
private extern static bool SetSystemTime(ref SYSTEMTIME lpSystemTime);
public static void SyncSystemTime(string strDateTime)
{
try
{
// Set the clock ahead one hour
SYSTEMTIME st = new SYSTEMTIME();
DateTime temp = Convert.ToDateTime(strDateTime);
st.wYear = (ushort)temp.Year;
st.wMonth = (ushort)temp.Month;
st.wDayOfWeek = (ushort)temp.DayOfWeek;
st.wDay = (ushort)temp.Day;
st.wHour = (ushort)temp.Hour;
st.wMinute = (ushort)temp.Minute;
st.wSecond = (ushort)temp.Second;
st.wMilliseconds = (ushort)temp.Millisecond;
if(!SetSystemTime(ref st))
{
myapp.Classes.Errors.LogNonExceptionError("Time not synced - " +
strDateTime,"Functions","SyncSystemTime","");
}
}
catch(Exception exc)
{
myapp.Classes.Errors.LogException(exc,"Functions","SyncSystemTime","");
}
}
ppc2003 device is not adjusting for DST (time behind by one hour). Here is
how I am setting it with the UTC time being passed to the function, should I
be doing this differently?
[DllImport("coredll.dll")]
private extern static bool SetSystemTime(ref SYSTEMTIME lpSystemTime);
public static void SyncSystemTime(string strDateTime)
{
try
{
// Set the clock ahead one hour
SYSTEMTIME st = new SYSTEMTIME();
DateTime temp = Convert.ToDateTime(strDateTime);
st.wYear = (ushort)temp.Year;
st.wMonth = (ushort)temp.Month;
st.wDayOfWeek = (ushort)temp.DayOfWeek;
st.wDay = (ushort)temp.Day;
st.wHour = (ushort)temp.Hour;
st.wMinute = (ushort)temp.Minute;
st.wSecond = (ushort)temp.Second;
st.wMilliseconds = (ushort)temp.Millisecond;
if(!SetSystemTime(ref st))
{
myapp.Classes.Errors.LogNonExceptionError("Time not synced - " +
strDateTime,"Functions","SyncSystemTime","");
}
}
catch(Exception exc)
{
myapp.Classes.Errors.LogException(exc,"Functions","SyncSystemTime","");
}
}