Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    time change for Germany

    Scheduled Pinned Locked Moved WiPy 2&3
    wipylopytime
    8 Posts 2 Posters 237 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W Offline
      Wolli01
      last edited by

      How to automate the time change for Germany via script. I get the time from nptime server.
      How do you do that for Germany?

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jcaron @Wolli01
        last edited by

        @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...

        W 1 Reply Last reply Reply Quote 0
        • W Offline
          Wolli01 @jcaron
          last edited by

          @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

          J 1 Reply Last reply Reply Quote 0
          • J Offline
            jcaron @Wolli01
            last edited by

            @Wolli01 where do you see it being used?

            W 1 Reply Last reply Reply Quote 0
            • W Offline
              Wolli01 @jcaron
              last edited by

              @jcaron said in time change for Germany:

              where do you see it being used?

              with me in Germany Nordrein Westphalia

              J 1 Reply Last reply Reply Quote 0
              • J Offline
                jcaron @Wolli01
                last edited by

                @Wolli01 I mean which function do you use that returns or parses local time?

                W 1 Reply Last reply Reply Quote 0
                • W Offline
                  Wolli01 @jcaron
                  last edited by

                  @jcaron

                  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])
                  
                  J 1 Reply Last reply Reply Quote 0
                  • J Offline
                    jcaron @Wolli01
                    last edited by

                    @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 (and mktime) using utime.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.

                    1 Reply Last reply Reply Quote 0

                    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
                    • 1 / 1
                    • First post
                      Last post

                    Pycom on Twitter

                    Pycom