question

jbakuwel avatar image
jbakuwel asked

Venus timezone

Hi all,

I'd like to retrieve the local time in a Python script running on Venus.

Venus is set to the correct timezone in the GUI ("New Zealand Standard Time") and shows the correct time too. The file system however does not reflect that; /etc/timezone contains "Universal".

Running "date" on the Venus command line shows UTC.

In Python there's also difference between UTC and local time:

Python 2.7.13 (default, Oct 16 2018, 12:48:19)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> print datetime.datetime.utcnow()
2019-06-29 00:48:51.582668
>>> print datetime.datetime.now()
2019-06-29 00:48:57.102877
>>> import time
>>> print time.localtime()
time.struct_time(tm_year=2019, tm_mon=6, tm_mday=29, tm_hour=0, tm_min=49, tm_sec=59, tm_wday=5, tm_yday=180, tm_isdst=0)


Any suggestions?

Jan


Venus OS
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

2 Answers
jeroen avatar image
jeroen answered ·

indeed, all dates are in UTC by default on purpose. If you do want the local time zone you can do this:

>>> import os, time
>>> time.strftime('%X %x %Z')
'12:54:00 07/02/19 UTC'
>>> os.environ['TZ'] = 'Europe/Amsterdam'
>>> time.strftime('%X %x %Z')
'14:54:05 07/02/19 CEST'

Localsettings has the user selected time zone.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

jbakuwel avatar image
jbakuwel answered ·

Thanks Jeroen!

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources