Time Functions in DIAL
The following calc functions work specifically with time.
Returns the elapsed time between two dates and times. The date1 and date2 arguments are in standard date format, and time1 and time2 are in standard time format. If both dates are not null, the difference between the dates is included in the elapsed time. If both times are not null, the difference in the times is included in the elapsed time. The result is returned as a standard time string. If the first date time pair is later than the second date time pair, the function returns a null string.
For example:
calc.elapsed_time("2021/06/25","10:25:00","2021/06/25","23:30:00"); returns 13:05:00
calc.elapsed_time("2021/07/04","00:00:00","2021/07/05","00:00:00"); returns 24:00:00
calc.elapsed_time("2021/06/20","23:30:00","2021/06/20","10:25:00"); returns a null string, ""
calc.elapsed_time ("2021/10/12",,"20210/10/14",); returns a syntax error
calc.elapsed_time ("2021/10/12","","2021/10/14",""); returns 48:00:00
calc.elapsed_time (,"10:25:00",,"08:25:00"); returns a syntax error
calc.elapsed_time ("","10:25:00","","08:25:00"); returns a null string
calc.elapsed_time ("","08:25:00","","10:25:00"); returns 02:00:00
Formats the string time_str according to the specified format and returns a standard time string in the format of HH:MM:SS.
For example:
calc.format_time("10:25", "hh:mm"); returns 10:25:00
calc.format_time("01 01 25 32", "dd hh mm ss"); returns 25:25:32
calc.format_time(TOD, "hh:mm"); where TOD contains 22:10, returns 22:10:00
calc.format_time("3600", "s"); returns 01:00:00
Returns, as a number, the number of hours in a standard time string.
For example:
calc.hours("20:15:05"); returns 20
Returns, as a number, the number of minutes in a standard time string.
For example:
calc.minutes("20:15:05"); returns 15
Returns the current time in a standard time string, HH:MM:SS.
Returns, as a number, the number of seconds in a standard time string.
For example:
calc.seconds("20:15:05"); returns 5
Adds two standard time strings together and returns a standard time string.
For example:
calc.time_add("11:00:00","12:00:00"); returns 23:00:00
Subtracts the second time argument from the first ( time1 - time2 ) and returns a standard time string. If the first argument is smaller than the second, the function returns a null string. Times cannot be negative.
For example:
calc.time_sub("23:00:00", "12:00:00"); returns 11:00:00
Converts a standard time string into a number of seconds.
For example:
calc.time_value("00:00:20"); returns 20
calc.time_value("00:05:00"); returns 300
calc.time_value("01:00:00"); returns 3600
calc.time_value("24:00:00"); returns 86400