Registry issue

Windows specific questions.
deltarho[1859]
Posts: 4557
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Registry issue

Post by deltarho[1859] »

@dodicat

I forgot to post your code working on "Pacific Standard Time"

Code: Select all

Time zone: Current:TIME_ZONE_ID_DAYLIGHT Bias: 480min (UTC=LocalTime+Bias)
 
  [Standard Name:"Pacific Standard Time" Bias:0min ]
"Pacific Standard Time"
First Sunday Nov
 
  [Daylight Name:"Pacific Summer Time" Bias:-60min ]
"Pacific Summer Time"
Second Sunday Mar
A batch file would be helpful. :)
dodicat
Posts: 8161
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Registry issue

Post by dodicat »

I get 139 time zones here using tzutil

Code: Select all

#include "vbcompat.bi"
#include "crt.bi"

Function gmt() As Double
    Dim As time_t rawtime
    Dim As zstring * 80 buffer
    time_(@rawtime)
    Var info = gmtime(@rawtime)
    strftime(buffer,80,"%d-%m-%Y", info)
    Var dv=Datevalue(buffer) 
    strftime(buffer,80,"%H:%M:%S", info)
    Var tv= Timevalue(buffer)
    Return dv+tv
End Function

Function Hours(_hours As Double) As Double
    Return (Int(_hours)/24)+(1/24)*Frac(_hours)
End Function

Sub pipeout(array() As String,Byval s As String)
    Var f=Freefile
    Dim As String tmp
    Dim As Long counter
    Open Pipe s For Input As #f 
    Do Until Eof(f)
        Line Input #f,tmp
        counter+=1
        Redim Preserve array(1 To counter)
        array(counter)=tmp
    Loop
    Close #f
End Sub

Function SAR(Byval s As String,Find As String,Replace As String) As String
    Var position=Instr(s,Find)
    While position>0
        s=Mid(s,1,position-1) & Replace & Mid(s,position+Len(Find))
        position=Instr(position+Len(Replace),s,Find)
    Wend
    Return s
End Function

Redim As String s()
pipeout(s(),"tzutil /l")
Dim As Double g=gmt
dim as ulong c
For n As Long=Lbound(s) To Ubound(s)
    Var g=Ltrim(s(n),"(UTC")
    Var i=Val(Mid(g,Instr(g,":")+1))/60
    g=sar(g,":",".")
    Var  v=Valint(g)+i
    If n Mod 3=1 Then 
        Color 15
        dim as string sign
        if v>=0 then sign="+" else sign=""
        Print s(n);Tab(65);Format(gmt+Hours(v), "ddd dd mmm yyyy hh:mm:ss");"   ";"(UTC ";sign;str(v);" hours)"
    Else
       if len(s(n)) then c+=1
        Color 3
        if len(s(n)) then  Print c;"  "; s(n);chr(10)
    End If
Next
Sleep


 
deltarho[1859]
Posts: 4557
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Registry issue

Post by deltarho[1859] »

Yours truly wrote:but I could not find one to fit 'Pacific Standard Time'.
That was using 'Time & Language" in Settings. Later on, I found it using 'tzutil /l'.

Now look at my following post where I changed my time znne to "Pacific Standard Time" and then used your code.
Last edited by deltarho[1859] on Oct 01, 2024 21:10, edited 1 time in total.
deltarho[1859]
Posts: 4557
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Registry issue

Post by deltarho[1859] »

Here is a batch file to do everything for us.

Run in admin mode.

I have called dodicat's code dodicatTZI.bas.

ChangeTimeZone.bat

Code: Select all

w32tm /config /manualpeerlist:,0x8 /syncfromflags:manual
net stop w32time
net start w32time
tzutil /s "Pacific Standard Time"
start "" "F:\FreeBASIC\TZI\dodicatTZI.exe"
tzutil /s "GMT Standard Time"
The system's time zone is changed to 'Pacific Standard Time' or whatever is your time zone of interest.

The output from dodicat's code, edit the path above, is displayed in a separate console window.

Your clock is then returned to its default time zone.

Change 'GMT Standard Time' to your default time zone.
Post Reply