strptime



  • 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



  • 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)



  • 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



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


Log in to reply
 

Pycom on Twitter