更新时间:2023-12-02 10:17:28
根据此 [ ^ ],SetSystemTime预期世界标准时间.您有考虑到这一点吗?如果不是,请此 [
According to this[^], the SetSystemTime is expecting UTC. Did you take that into account? If not, this[^] might help.
UTC是否与之相关?它和夏时制
从什么时候开始改变时间变得如此复杂
添加了几行转换为GMT而不是现在的GMT + 1
因此,这意味着我现在要使用昨天23:00的日期和时间来更新时钟,但是GMT + 1(夏令时)设置正确了.
但是如果没有您的帮助我就不会实现
现在输入代码
Are UTC does have something to do with it and daylight saving time
Since when did changing the time become so complicated
Have added a couple of lines that convert to is GMT not GMT+1 as it is now
So this mean I go into updating the clock now with a date and time for 23:00 yesterday, but GMT+1 (daylightsaving) puts it right.
But I wouldn''t have got there with out your help
Code now
If (DIOdata And DiMask2) = 0 Then 'Time Syncronisation
DateTimeSync = False 'NO
ElseIf Not DateTimeSync Then 'Not yet Syncronised
Midnight1 = Format(Date.Now, "dd/MM/yyyy")
Midnight2 = Format(Date.Now, "dd/MM/yyyy") + " 23:59:59"
Test1 = Math.Abs(DateDiff(DateInterval.Second, Now(), Midnight1)) 'calculates number of seconds so far today
Test2 = Math.Abs(DateDiff(DateInterval.Second, Now(), Midnight2) + 1) 'calculates number seconds time end of day
If Test1 > Test2 Then Midnight1 = Midnight1.AddDays(1)
Dim Othertime As DateTimeOffset = New DateTimeOffset(Midnight1)
Othertime = Othertime.ToOffset(TimeSpan.Zero)
timeStru.wDay = Othertime.Day
timeStru.wMonth = Othertime.Month
timeStru.wYear = Othertime.Year
timeStru.wHour = Othertime.Hour
timeStru.wMilliseconds = Othertime.Millisecond
timeStru.wMinute = Othertime.Minute
timeStru.wSecond = Othertime.Second
SetSystemTime(timeStru)
DateTimeSync = True
ESDsync = True
End If
干杯
Cheers