time change for Germany
-
How to automate the time change for Germany via script. I get the time from nptime server.
How do you do that for Germany?
-
@Wolli01 Don't have a Pycom module at hand to test, but does that actually return local time by default? If so, I wonder where it could possibly get the timezone from... But a quick glance through the code makes me think it doesn't, does it?
You can control the timezone used by
localtime
(andmktime
) usingutime.timezone
, but it's simplistic (just an offset from UTC), it does not handle automatic DST changes. If you want that to be handled for you (which seems overkill on such a device IMHO) you'll probably have to use an external library that supports it.
-
rtc.ntp_sync("de.pool.ntp.org") while not rtc.synced(): machine.idle() # save power while waiting time1 = utime.localtime() # Übergabe Datum und Uhrzeit in die Variable time1 print (time1) startzeit = time.time() LogDateTime = "{}.{:}.{:};{:0>2d}:{:0>2d}:{:0>2d}".format(time1[2], time1[1], time1[0], time1[3], time1[4], time1[5]) LogDate = "{}.{:}.{:}".format(time1[2], time1[1], time1[0]) LogTime = "{:0>2d}:{:0>2d}:{:0>2d}".format(time1[3], time1[4], time1[5])
-
@Wolli01 I mean which function do you use that returns or parses local time?
-
@jcaron said in time change for Germany:
where do you see it being used?
with me in Germany Nordrein Westphalia
-
@Wolli01 where do you see it being used?
-
@jcaron said in time change for Germany:
what time change are you referring to? The switch from winter to summer time? I don’t think any of the built-in functions deal with local time anyway (only UTC), do they?
If you are using functions that deal with local time, they must have a way to define a timezone which will take this into account...yes winter to summer time
-
@Wolli01 what time change are you referring to? The switch from winter to summer time? I don’t think any of the built-in functions deal with local time anyway (only UTC), do they?
If you are using functions that deal with local time, they must have a way to define a timezone which will take this into account...