On Friday, 28 August 2015 at 14:07:37 UTC, wobbles wrote:
However, it just returns an empty string.
from the doc:
Note that this always returns the empty string. This is because
time zones cannot be uniquely identified by the attributes given
by the OS (such as the stdName and dstName), and neither Posix
systems nor Windows systems provide an easy way to get the TZ
Database name of the local time zone.
Anyone know how to get the timezone of the machine easily?
Best you can do is try the stdName or dstName properties of
Timezone, perhaps checking if dstInEffect to choose which one to
print. Or ou could use the utcOffsetAt function to print a number
(like UTC-4:00, after formatting it)
The actual location the user sets in the timezone settings of the
computer I think the docs are right about - it isn't available on
either OS, even using platform specific APIs... though I'm sure
it is stored somewhere and maybe you could e.g. dig into the
Windows registry to find it.