On Tuesday, February 13, 2018 at 10:34:45 AM UTC, Dr J R Stockton wrote:
> On Tuesday, February 13, 2018 at 3:21:41 AM UTC, David Solimano wrote:
> > Would something like this work
> >
> >
https://stackoverflow.com/a/22842128/58074
> >
> > Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
> > dateTime.SetVarDate (now())
> > wscript.echo "Local Time: " & dateTime
> > wscript.echo "UTC Time: " & dateTime.GetVarDate (false)
> >
> > Using your date instead of now()?
>
> YES!
> The background is that, in all my browsers, JavaScript correctly uses the
> UK/EU rules for Summer Time, but I have observed that at the "MS-DOS"
> command line cscript filename.JS uses the US DST rules, which is an
> objectionable bug. Therefore, I began to wonder what the situation might be
> with cscript filename.VBS .
>
> VBScript proper uses only local date/time with only 24-hour days, so cannot
> show the bug unaided. Using WbemScripting, which I do not know enough
> about, the absence of a corresponding bug is easily shown.
=============
But there is a non-corresponding bug. Using the code cited above in a loop. I stepped through several years of Local Noon, finding changes on the correct dates. The results obtained by stepping minute-by-minute through local time were confusing, since each year an hour of local time is, for much of the world, omitted, and an hour is duplicated. So I changed to using the next bit of code on the cited page, to step minute-by-minute through three years of GMT.
That showed (in the UK) that the autumn change is one hour late in Win XP sp3 and in current Win 7, but is correct in Win 10.
Apparently there are other ways of getting the offset of local time from
UTC; I don't know what results they might give.
Executable Code :
WScript.echo ""
WScript.echo "(c) J R Stockton >= 2018-02-15"
WScript.echo "Use : Prompt> cscript //nologo TIME-BUG.VBS"
'' See
https://stackoverflow.com/questions/15887700/utc-time-assignment-in-vbscript/22842128#22842128 (unwrapped)
WScript.echo ""
Set DT = CreateObject("WbemScripting.SWbemDateTime")
Dim XS, XOff
Sub SubRtn2(K)
DT.SetVarDate CDate(D0+K), false '' Where Arg 1 is the UTC date
UTC = CDate(DT.GetVarDate(false))
DoW = " " & WeekdayName(Weekday(UTC))
LCT = CDate(DT.GetVarDate(true))
Off = CInt((CDate(LCT) - CDate(UTC)) * 1440) '' minutes
S = " UTC = " & UTC & DoW & ", LCT = " & LCT & ", Offset = " & Off
if ((K<>0) and (XOff<>Off)) then _
WScript.echo XS & vbCrLf & S & vbCrLf
XS = S : XOff = Off
End Sub
WScript.echo " Check every UTC mid-minute for three years :" & _
vbCrLf & " In the EU all offset changes are at 01:00 GMT/UTC," & _
vbCrLf & " on the last Sunday of March/October." & vbCrLf
D0 = CDate("2015/12/31 12:00:30") '' Represents UTC
for K = 0 to 3*366*1440 : SubRtn2(K/1440) : next '' step minutes
WScript.echo " In my UK PCs, time shift date/times are :-" & vbCrLf & _
" Win7 & Win7 XP VM, & UK WinXP, Autumn - one hour late." & vbCrLf & _
" 2 * Win10, Spring and Autumn - OK."
WScript.echo vbCrLf & "End of TIME-BUG.VBS"
*** I have since seen that this bug was reported last year by a user in
*** mainland Europe, where civil time is always an hour ahead of UK time.