S
Saul
Hi all!
Well, I admit it, I don't really know the best way to solve this problem, so
I thought I'd ask the braintrust here.
I have a pocketPC device which is syncing to a SQL server. I send back the
servers datetime as part of the sync. The problem is that I want to make
sure that the handhelds date and time is within a few hours of the server,
if not, set it to the same times as the server. As this app will be deployed
all over Australia, local time might be several hours different to the
server (in Sydney). I am ok with getting it "close" if it's way off, even if
it's not to the hour accurate. What I really want to stop is people who have
not set the date correctly and are in 2000 for example. The data I am
collecting is timestamped with the local (handheld) time, so it's kinda
important.
I have discovered in the FAQ how to set the PocketPC time, which is great.
This relies apon a systemtime structure as follows..
Public Structure SYSTEMTIME
' See
http://msdn.microsoft.com/smartclient/understanding/netcf/FAQ/default.aspx#6.16
' used for changing datetime on unit
Public wYear As UInt16
Public wMonth As UInt16
Public wDayOfWeek As UInt16
Public wDay As UInt16
Public wHour As UInt16
Public wMinute As UInt16
Public wSecond As UInt16
Public wMilliseconds As UInt16
End Structure
Ok, so armed with the server date/time as a string (eg "10/2/2005 1:15:25
PM") how do I best compare this to now() to see if it's wrong by more than 4
hours, and then put what it should be (from the server string again) into
the structure above to update the time/date?
The things that are freaking me out are - if it's done close to midnight (so
the days will be different), or midnight end of month (month different) or
midnight new years eve (unlikely, everyone will be too drunk for that, but
you know). I am also really not confident either in converting the string
into a comparable date. For example, the day and month don't have leading
zeros so how best to pull them out? As usual, I'm probably missing a whole
bunch of really obvious things.
Any and all help greatly appreciated. Thanks for reading this and post here
if you want me to clarify anything!
Regards,
Saul
Well, I admit it, I don't really know the best way to solve this problem, so
I thought I'd ask the braintrust here.
I have a pocketPC device which is syncing to a SQL server. I send back the
servers datetime as part of the sync. The problem is that I want to make
sure that the handhelds date and time is within a few hours of the server,
if not, set it to the same times as the server. As this app will be deployed
all over Australia, local time might be several hours different to the
server (in Sydney). I am ok with getting it "close" if it's way off, even if
it's not to the hour accurate. What I really want to stop is people who have
not set the date correctly and are in 2000 for example. The data I am
collecting is timestamped with the local (handheld) time, so it's kinda
important.
I have discovered in the FAQ how to set the PocketPC time, which is great.
This relies apon a systemtime structure as follows..
Public Structure SYSTEMTIME
' See
http://msdn.microsoft.com/smartclient/understanding/netcf/FAQ/default.aspx#6.16
' used for changing datetime on unit
Public wYear As UInt16
Public wMonth As UInt16
Public wDayOfWeek As UInt16
Public wDay As UInt16
Public wHour As UInt16
Public wMinute As UInt16
Public wSecond As UInt16
Public wMilliseconds As UInt16
End Structure
Ok, so armed with the server date/time as a string (eg "10/2/2005 1:15:25
PM") how do I best compare this to now() to see if it's wrong by more than 4
hours, and then put what it should be (from the server string again) into
the structure above to update the time/date?
The things that are freaking me out are - if it's done close to midnight (so
the days will be different), or midnight end of month (month different) or
midnight new years eve (unlikely, everyone will be too drunk for that, but
you know). I am also really not confident either in converting the string
into a comparable date. For example, the day and month don't have leading
zeros so how best to pull them out? As usual, I'm probably missing a whole
bunch of really obvious things.
Any and all help greatly appreciated. Thanks for reading this and post here
if you want me to clarify anything!
Regards,
Saul