Search code examples
gnuplot

gnuplot is it possible to make addition of time value


who cant tell me how to make an addition of time in gnuplot.

I am trying to do this :

StartTime="09:23:20"
EndTime="12:45:34"
Delay="00:03:23"

Action=StartTime + Delay

or

set xrange [("10:23:45"+Delay): EndTime]

But it is not working as i expect.

Thanks


Solution

  • Gnuplot stores time values internally as a floating point number. The functions to convert back and forth between this and a formatted representation of time are strptime("timeformat", "mytime") and strftime("timeformat", sec). So you want something along the lines of

    Start_sec = strptime("%H:%M:%S", StartTime)
    Delay_sec = strptime("%tH:%tM:%tS", Delay)
    Action_sec = Start_sec + Delay_sec
    ActionTime = strftime("%H:%M:%S", Action_sec)
    

    Note that the delay is an time interval, not a date or time-of-day, so it needs a different format. See the documentation under "help time_spec". Or you could just provide as a number of seconds

    Action_sec = 123.4