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

    strptime

    Scheduled Pinned Locked Moved MicroPython
    4 Posts 2 Posters 260 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.
    • P Offline
      Phil
      last edited by

      I believe this function is not available, what is the workaround?

      ReportingTimeSTR = "2019-01-01 {}:{}:{}".format(ReportingTime[0:2], ReportingTime[2:4], ReportingTime[4:6])
      RT = datetime.strptime(ReportingTimeSTR, '%Y-%m-%d %H:%M:%S')

      Thanks

      S 1 Reply Last reply Reply Quote 0
      • S Offline
        Steve Williams @Phil
        last edited by Steve Williams

        @Phil Depending, what you are using it on and how you use the time information, would utime.localtime() give you the information you need? As a tuple it isn't hard to format the returned data into a string.

        1 Reply Last reply Reply Quote 0
        • P Offline
          Phil
          last edited by

          It hands back a proper Time Structure:
          typedef struct _timeutils_struct_time_t {
          uint16_t tm_year; // i.e. 2014
          uint8_t tm_mon; // 1..12
          uint8_t tm_mday; // 1..31
          uint8_t tm_hour; // 0..23
          uint8_t tm_min; // 0..59
          uint8_t tm_sec; // 0..59
          uint8_t tm_wday; // 0..6 0 = Monday
          uint16_t tm_yday; // 1..366
          } timeutils_struct_time_t;

          Then maybe..., Thanks

          1 Reply Last reply Reply Quote 0
          • P Offline
            Phil
            last edited by

            Actually I think I can do what I need by using mktime() :

            t = (2009, 2, 17, 17, 3, 38, 1, 48, 0)
            secs = time.mktime( t )
            print("time.mktime(t) : %f" % secs)

            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