Re: Daylight Saving

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 07/29/04


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


Relevant Pages

  • Re: Object Rexx to become Open Source
    ... Granted WSH is not a language. ... >> up quickly, then the knock against JScript would be that, because it is ... never said that JScript was bad or even not as good a language as VBScript; ... But our official standard scripting language for such things as logon ...
    (microsoft.public.scripting.wsh)
  • Re: Object Rexx to become Open Source
    ... We were talking "languages", WSH is just an interface to the o/s. ... > as provided by some other scripting languages, I have found it a significant ... source" on any of their pages and you'll see it's JScript all the way. ... also can't imagine using VBScript for XML?? ...
    (microsoft.public.scripting.wsh)
  • Re: vbs or jscript?
    ... This is done in 100% JScript, ... I definitely see the reason why not to use VBScript in the ... > World's worse scripting language in my opinion. ... > regular expression, tidy code, universal language, C-style, etc. ...
    (microsoft.public.scripting.wsh)
  • Re: VBScript Vs. Javascript
    ... I'm new to windows scripting! ... All the things that can be done in VBScript can be done by JScript? ... > That's about it really [apart from the obvious syntactic differences areas ...
    (microsoft.public.scripting.vbscript)
  • VBScript/JScript comparison
    ... differences between VBScript and JScript. ... reference types (objects, arrays, functions) are always passed by reference. ... Enumerator object's itemmethod. ...
    (microsoft.public.scripting.wsh)