Listmates,
I need to convert times for clients, the file server time is set to central. When we auto add a date for the client, it uses the servers bios clock. Should the user profile be set to Pacific, I want to convert it for them. Has anybody tackled this issue before?
Thanks in Advance
Roy
This is not trivial to do especially in FoxPro since it has no native support for UTC dates and time zone conversions.
The generally accepted way to do this is to store all dates in UTC format in the database and then perform whatever adjustments you need to to display the dates to users.
Web Connection provides a number of functions that can help with that, but it's not quite everything you need:
In fact, I looked at FromUtcTime()
and realized that it would greatly benefit from having a timezone offset attached to it so you can adjust for a given offset.
The adjusted function looks like this:
************************************************************************
* FromUtcTime
****************************************
*** Function: Returns local time from UTC Time
*** Assume:
*** Pass: ltTime - UTC Time
*** lnOffsetMinutes - optional offset minutes
*** Return:
************************************************************************
FUNCTION FromUtcTime(ltTime, lnOffsetMinutes)
LOCAL lnOffset
IF VARTYPE(lnOffsetMinutes) # "N"
lnOffset = GetTimeZone() * 60
ELSE
lnOffset = lnOffsetMinutes * 60
ENDIF
RETURN ltTime - lnOffset
ENDFUNC
* FromUtcTime
Using these functions you can store UTC dates in the database, and then adjust dates for a user setting (or local time) stored with each user.
+++ Rick ---