Skip to content

Instantly share code, notes, and snippets.

@aeppert
Last active February 17, 2020 03:25
Show Gist options
  • Select an option

  • Save aeppert/9243af222e1f47b44a62 to your computer and use it in GitHub Desktop.

Select an option

Save aeppert/9243af222e1f47b44a62 to your computer and use it in GitHub Desktop.
Calculate elapsed time given two times
export {
type timeSpan: record {
hours: int;
minutes: int;
seconds: int;
};
}
function calc_elapsed_time(t1: time, t2: time) : timeSpan
{
local ret: timeSpan;
local timeInterval = double_to_count(time_to_double(t2) - time_to_double(t1));
ret$hours = (timeInterval / 3600);
ret$minutes = (timeInterval - (ret$hours * 3600)) / 60;
ret$seconds = (timeInterval % 60);
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment