#193827 - 2009-05-13 05:09 PM
Re: about Sync Time (include timezone setting)
[Re: Glenn Barnas]
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Too many differents there for me
|
|
Top
|
|
|
|
#193850 - 2009-05-14 02:54 PM
Re: about Sync Time (include timezone setting)
[Re: Gargoyle]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
|
Hmm.. don't think so.. NTP and NT5DS protocols don't deal with time zones, just time. My laptop is set for EST/EDT, but if I travel to our site in Australia and sync with the local DC there, it will still display EST/EDT time (and quite accurately, too, since I'm syncing to a local authoritative time source!) We have a highly accurate time environment here, using NTP on all servers and the PDCe, NT5DS on the other DCs and workstations. Our retail locations throughout all of North America sync to DCs in the NYC metro area, and all have locally defined timezone settings.
Now that the OP has clarified that it is a travelling laptop that needs to adjust to a different, local time zone, the challenge becomes clear. You need to have some way to identify that the network location is a different time zone.
You can't simply query the DC because the site you're at might not have one, or you could authenticate to your "home" DC.
AD Sites might work, but they might not be configured, or might span a timezone border. Subnets, however would rarely (ok, prolly never!) cross a timezone border. (imagine the grief of a business office split by a time zone! )
So, assuming that you could create a translation between subnet ranges and timezones, you could potentially update the timezone setting during logon. However, since timezone is a machine and not a user setting, I'm thinking that it won't be as simple as plugging values into the registry. Might need a reboot or minimally a restart of the W32time service - not sure. Of course, if those actions are needed, the code would have to be smart enough to trigger them only if it actually changed the timezone value.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#193869 - 2009-05-14 04:21 PM
Re: about Sync Time (include timezone setting)
[Re: Gargoyle]
|
BradV
Seasoned Scripter
  
Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
|
Or try to educate users that their laptop is always going to display time in the "home" time zone.
Argh, not sure what I was thinking. That will never work.
|
|
Top
|
|
|
|
#193906 - 2009-05-15 10:32 PM
Re: about Sync Time (include timezone setting)
[Re: Allen]
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
If it is going against the atomic clock and you have sntp services setup correctly, the tz should be set correctly..
Other than that, you are correct..
Kent
|
|
Top
|
|
|
|
#193908 - 2009-05-16 12:23 AM
Re: about Sync Time (include timezone setting)
[Re: Glenn Barnas]
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
|
|
Top
|
|
|
|
#193909 - 2009-05-16 12:38 AM
Re: about Sync Time (include timezone setting)
[Re: Kdyer]
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4567
Loc: USA
|
No apologies needed bud. None of us are getting paid to do this you know 
I think AutoIT can do it though...
; #FUNCTION# ====================================================================================================================
; Name...........: _Date_Time_SetTimeZoneInformation
; Description ...: Sets the current time zone settings
; Syntax.........: _Date_Time_SetTimeZoneInformation($iBias, $sStdName, $tStdDate, $iStdBias, $sDayName, $tDayDate, $iDayBias)
; Parameters ....: $iBias - The current bias for local time translation on this computer. The bias is the difference in
; +minutes between Coordinated Universal Time (UTC) and local time. All translations between UTC and local time
; +use the following formula: UTC = local time + bias
; $sStdName - The description for standard time
; $tStdDate - A %tagSYSTEMTIME structure that contains a date and local time when the transition from
; +daylight saving time to standard time occurs.
; $iStdBias - The bias value to be used during local time translations that occur during standard time. This
; +value is added to the value of the Bias to form the bias used during standard time. In most time zones, this
; +value is zero.
; $sDayName - The description for daylight saving time
; $tDayDate - A %tagSYSTEMTIME structure that contains a date and local time when the transition from
; +standard time to daylight saving time occurs.
; $iDayBias - The bias value to be used during local time translation that occur during daylight saving time.
; +This value is added to the value of the Bias member to form the bias used during daylight saving time. In
; +most time zones this value is –60.
; Return values .: Success - True
; Failure - False
; Author ........: Paul Campbell (PaulIA)
; Modified.......: Gary Frost (gafrost)
; Remarks .......:
; Related .......: _Date_Time_GetTimeZoneInformation, $tagSYSTEMTIME
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================
Func _Date_Time_SetTimeZoneInformation($iBias, $sStdName, $tStdDate, $iStdBias, $sDayName, $tDayDate, $iDayBias)
Local $hToken, $tStdName, $tDayName, $tZoneInfo, $aResult
$tStdName = _WinAPI_MultiByteToWideChar($sStdName)
$tDayName = _WinAPI_MultiByteToWideChar($sDayName)
$tZoneInfo = DllStructCreate($tagTIME_ZONE_INFORMATION)
DllStructSetData($tZoneInfo, "Bias", $iBias)
DllStructSetData($tZoneInfo, "StdName", DllStructGetData($tStdName, 1))
_MemMoveMemory(DllStructGetPtr($tStdDate), DllStructGetPtr($tZoneInfo, "StdDate"), DllStructGetSize($tStdDate))
DllStructSetData($tZoneInfo, "StdBias", $iStdBias)
DllStructSetData($tZoneInfo, "DayName", DllStructGetData($tDayName, 1))
_MemMoveMemory(DllStructGetPtr($tDayDate), DllStructGetPtr($tZoneInfo, "DayDate"), DllStructGetSize($tDayDate))
DllStructSetData($tZoneInfo, "DayBias", $iDayBias)
; Enable system time privileged mode
$hToken = _Security__OpenThreadTokenEx(BitOR($__DATECONSTANT_TOKEN_ADJUST_PRIVILEGES, $__DATECONSTANT_TOKEN_QUERY))
_WinAPI_Check("_Date_Time_SetSystemTimeAjustment:OpenThreadTokenEx", @error, @extended)
_Security__SetPrivilege($hToken, "SeSystemtimePrivilege", True)
_WinAPI_Check("_Date_Time_SetSystemTimeAjustment:SetPrivilege:Enable", @error, @extended)
; Set time zone information
$aResult = DllCall("Kernel32.dll", "int", "SetTimeZoneInformation", "ptr", DllStructGetPtr($tZoneInfo))
; Disable system time privileged mode
_Security__SetPrivilege($hToken, "SeSystemtimePrivilege", False)
_WinAPI_Check("_Date_Time_SetSystemTimeAdjustment:SetPrivilege:Disable", @error, @extended)
_WinAPI_CloseHandle($hToken)
Return SetError($aResult[0] = 0, 0, $aResult[0] <> 0)
EndFunc ;==>_Date_Time_SetTimeZoneInformation
Maybe? If so, it just another time when I absolutely hate it when our "competition" can do something we can't.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 476 anonymous users online.
|
|
|