Re: Daylight Saving
From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 07/29/04
- Next message: Csaba Gabor: "Re: createobject("window.manager") doesn't work in windows 2000?"
- Previous message: Torgeir Bakken \(MVP\): "Re: Configuring Outlook XP with script"
- In reply to: Gorge Bush: "Daylight Saving"
- Next in thread: Dr John Stockton: "Re: Daylight Saving"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 29 Jul 2004 15:31:51 +0200
Gorge Bush wrote:
> Hi there,
> how do I determine whether or not we are in daylight saving
> time of normal time. ie: GMT or BST? There are loads or functions for this
> in JScript but nothing in VBScript.
Hi
Here is a script from Michael Harris:
'--------------------8<----------------------
set shell = createobject("wscript.shell")
' ActiveTimeBias is the number of minutes that UTC
' is offset from local time adjusted for daylight
' savings time. Bias is the same value but *not*
' adjusted.
'
' If both are the same, daylight savings time is
' *not* in effect...
'
sTZInfoKey = _
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\" _
& "TimeZoneInformation\"
sActiveTimeBias = "ActiveTimeBias"
sBias = "Bias"
nActiveTimeBias = shell.regread(sTZInfoKey & sActiveTimeBias)
nBias = shell.regread(sTZInfoKey & sBias)
bDstInEffect = Not (nActiveTimeBias = nBias)
MsgBox "Dst status: " & bDstInEffect
'--------------------8<----------------------
You can also use Walter Zackery's elegant approach to calling
JScript routines from VBScript:
'--------------------8<----------------------
WScript.Echo "Time zone offset (min): " & getTimeZoneOffset
Function getTimeZoneOffset() ' VBScript call to JScript routine
Dim oJS
Set oJS = CreateObject("htmlfile")
oJS.Write("<script>d=new Date();a=d.getTimezoneOffset()</script>")
oJS.Close
getTimeZoneOffset = oJS.parentWindow.a
End Function
'--------------------8<----------------------
-- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx
- Next message: Csaba Gabor: "Re: createobject("window.manager") doesn't work in windows 2000?"
- Previous message: Torgeir Bakken \(MVP\): "Re: Configuring Outlook XP with script"
- In reply to: Gorge Bush: "Daylight Saving"
- Next in thread: Dr John Stockton: "Re: Daylight Saving"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|