Back to Aurora Vision Library Lite website

You are here: Start » System » Time » SplitDurationToParts

SplitDurationToParts


Header: STD.h
Namespace: avl

Computes components of a duration.

Syntax

C++
Python
 
void avl::SplitDurationToParts
(
	const avl::Duration& inDuration,
	int& outDaysPart,
	int& outHoursPart,
	int& outMinutesPart,
	int& outSecondsPart,
	int& outNanosecondsPart,
	double& outTotalDays,
	double& outTotalHours,
	double& outTotalMinutes,
	double& outTotalSeconds,
	double& outTotalNanoseconds
)

Parameters

Name Type Default Description
Input value inDuration const Duration& Duration to split
Output value outDaysPart int& Integer number of days
Output value outHoursPart int& Integer number of hours (in range <-23;23>)
Output value outMinutesPart int& Integer number of minutes (in range <-59;59>)
Output value outSecondsPart int& Integer number of seconds (in range <-59;59>)
Output value outNanosecondsPart int& Integer number of nanoseconds (in range <-999999999;999999999>)
Output value outTotalDays double& Total duration expressed in days
Output value outTotalHours double& Total duration expressed in hours
Output value outTotalMinutes double& Total duration expressed in minutes
Output value outTotalSeconds double& Total duration expressed in seconds
Output value outTotalNanoseconds double& Total duration expressed in nanoseconds

Remarks

Note the subtle difference between outDaysPart, outHoursPart, ... outputs and outTotalDays, outTotalHours, ... outputs. For example, let us assume a duration of 28.5 hours.

  • If one needs to do calculations on it, like dividing by 2, use outTotalHours output or any other Total output.
  • If one needs to display the duration to the user as hours, minutes and seconds (like "28:30:00"); use integer part of outTotalHours together with outMinutesPart and outSecondsPart. That way the hours part will not overflow if the duration is longer than one day.

Note that if a negative duration is provided, every output will also be negative or equal to zero.

Assumptions about date and time calculations:

  • Timestamp should always be in UTC (Coordinated Universal Time).
  • Timestamp can be converted to DateTime using either UTC or local timezone. Other timezones are not supported. However, the timezone offset is saved in DateTime so one can always convert back to UTC.
  • Conversion to local time should take into account daylight saving time (summer/winter time), if configured in the operating system. However, usually only currently applicable DST rules are used, so calculations may be incorrect if they refer to a period when the rules were different.
  • Timestamp resolution is 100 nanoseconds.
  • Timestamp is 64-bit, so should support dates about 29000 years in the past or future. However, the whole range may not be supported when converting to local timezone.
  • Dates are calculated in proleptic Gregorian calendar.
  • Leap seconds are ignored, like in Unix time.