Time in Gridlabd

  • Pedram Jahangiri


    I want to add some codes in solar.cpp. I need to get the clock (current simulation time in second, min, hour, day, month, year like a time stamp) in the codes. What is the piece of code (or function) which I need to convert t0 (number of second elapsed since epoch) to time stamp format?

    Thank you,

  • Jason Fuller

    Jason Fuller - 2013-01-11


    There are a couple of options.

    The one I use a lot is to convert the time to a structure (a good example is in the triplex meter):

    DATETIME my_time;
    // then you can access it by
    double my_day = my_time.day;
    // and convert it back to epoch time
    TIMESTAMP next_time = gl_mktime(&my_time);

    but there are a number of other options (gl_parsetime, gl_printtime, gl_strtime, gl_todays, etc.) Most of these are documented on the WIKI, but definitely not all.  All of the available time handling functions can be found in ../core/gridlabd.h; search for the header "Timestamp handling"


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks