Drycoded:
Code:
local function timezoneOffset()
local realmHour,realmMin = GetGameTime()
local utcHour, utcMin = tonumber(date("!%H")), tonumber(date("!%M"))
local hourOffset = realmHour - utcHour
local minOffset = realmMin - utcMin
if minOffset < -30 then
hourOffset = hourOffset - 1
elseif minOffset > 30 then
hourOffset = hourOffset + 1
end
return hourOffset
end
As long as the local clock is within 30 minutes of the server's clock, this should give you the time zone of the server.
From here, you have two options:
1) Assume everything below, say, UTC-3 is an US realm, and everything above UTC-3 is an EU realm. Other regions would require adjustments.
2) Keep a database of every realm name, all occurrences of that realm name and the respective server time zones. First index with GetRealmName(), then check for the closest match (or assume a default language [english? the client's locale?] if no exact match is found).
PS: Someone should make a library that does this.