Set Browser Time zone (more than four letters) [duplicate]

ε祈祈猫儿з 提交于 2019-12-19 10:54:10

问题


SET TZ=AEST -9
"c:\Program Files (x86)\Mozilla Firefox\firefox.exe"

Test against: https://whoer.net/ . Notice how it displays AES and not AEST and the -9 does not get recognized.

Not really sure if there is a workaround for this and the fact you can change your OS time through your browser is amazing. But thought I'd ask, has anyone gotten around this issue?

If I put in UTC -9 that would work but I'm testing for words above 3 letters.


回答1:


A few things:

  • The TZ variable must meet the POSIX time zone specification, of the first or second formats described here. The space in your string makes the identifier invalid.
  • AEST is typically used for Australian Eastern Standard Time, which is UTC+10, not UTC+9.

    • As the POSIX form has the sign inverted, you would use AEST-10 if you intended to represent the time in Queensland that is UTC+10 year-round.
    • If you meant to represent NSW (Sydney, etc.), then you need a much more complex identifier to represent the current time zone rules: AEST-10AEDT,M10.1.0,M4.1.0/3

    • In general, POSIX time zone strings should not be used in most cases. They are insufficient to work with all the time zones of the world, as they cannot represent historical changes or more than two transitions in a year. This is also discussed in the timezone tag wiki.

  • Ideally, you'd use the third format of the TZ variable, which is an IANA tzdb identifier, such as Australia/Brisbane or Australia/Sydney, however this will not work on Windows OS. You can only use this for Linux, OSX, etc.

  • In general, setting the TZ variable on Windows isn't reliable, as only certain APIs will use it at all. For example, the Windows C Run-Time Library's localtime function will use TZ variable, but the Win32 API's GetTimeZoneInformation function will not. Since one generally has no idea what the internals of the application are doing, it's not reasonable to expect the TZ variable to function in all cases. Indeed, while FireFox currently works, it may stop working with it in some future release - and it doesn't work for other browsers like Chrome and Edge.

  • There currently is no reliable way to set the time zone for a single process on Windows.



来源:https://stackoverflow.com/questions/45253162/set-browser-time-zone-more-than-four-letters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!