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 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...
-
@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 where do you see it being used?
-
@jcaron said in time change for Germany:
where do you see it being used?
with me in Germany Nordrein Westphalia
-
@Wolli01 I mean which function do you use that returns or parses local time?
-
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 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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login