ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Determining the player's timezone (https://www.esoui.com/forums/showthread.php?t=4988)

kerb9729 08/09/15 09:13 AM

Determining the player's timezone
 
GetTimeStamp() seems to return the time in UTC.

Is there any way to determine the current system timezone without forcing the user to configure it?

I suppose I could calculate it by converting GetTimeString() to a unix timestamp somehow, but it seems like there should be a better way.

I have a simple addon that predicts what time an in-game time will occur in real time and displays it in the chat window. It gets game time from the "Tamriel Standard Time" addon. So I guess in reality it's an addon to an addon.

Currently I just hard code my timezone, but I thought I might clean it up and release it. Or give the code to "Tamriel Standard Time" guy so he can incorporate it into his addon if he wants.

It's pretty useful if you are trying to become a vamp or ww the hard way. It's nice to know what time you need to be online to check the spawns.

votan 08/09/15 09:25 AM

Quote:

Originally Posted by kerb9729 (Post 22604)
GetTimeStamp() seems to return the time in UTC.

Is there any way to determine the current system timezone without forcing the user to configure it?

I suppose I could calculate it by converting GetTimeString() to a unix timestamp somehow, but it seems like there should be a better way.

I have a little 5 line addon that predicts what time an in-game time will occur in real time and displays it in the chat window. It gets game time from the "Tamriel Standard Time" addon. So I guess in reality it's an addon to an addon.

Currently I just hard code my timezone, but I thought I might clean it up and release it. Or give the code to "Tamriel Standard Time" guy so he can incorporate it into his addon if he wants.

It's pretty useful if you are trying to become a vamp or ww the hard way. It's nice to know what time you need to be online to check the spawns.

The way I found is:
Lua Code:
  1. local localTimeShift = GetSecondsSinceMidnight() -(GetTimeStamp() % 86400)
  2.   if localTimeShift < -12 * 60 * 60 then localTimeShift = localTimeShift + 86400 end
And yes, GetTimeStamp() is UTC and GetSecondsSinceMidnight() is current clients time including daylight saving.

kerb9729 08/09/15 09:33 AM

Quote:

Originally Posted by votan (Post 22606)
The way I found is:
Lua Code:
  1. local localTimeShift = GetSecondsSinceMidnight() -(GetTimeStamp() % 86400)
  2.   if localTimeShift < -12 * 60 * 60 then localTimeShift = localTimeShift + 86400 end
And yes, GetTimeStamp() is UTC and GetSecondsSinceMidnight() is current clients time including daylight saving.

This is exactly what I needed, thanks very much!


All times are GMT -6. The time now is 05:18 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI