/* Create a new timespan_t based on the specified number of nanoseconds/ticks.  */
err_t timespanCreate(int64_t ticks, timespan_t *timespan)
/* Create a new timespan_t based on the specified number of nanoseconds/ticks.  */
err_t timespanCreate(int64_t ticks, timespan_t *timespan)
{
  if (timespan == NULL)
  {
    return ERROR_INVALIDPARAMETER;
  }
  memcpy(timespan, 0, sizeof(timespan_t));
  timespan->days = (ticks / TIMESPAN_NANOSPERDAY);
  timespan->hours = (ticks / TIMESPAN_NANOSPERHOUR) % 24;
  timespan->minutes = (ticks / TIMESPAN_NANOSPERMINUTE) % 60;
  timespan->seconds = (ticks / TIMESPAN_NANOSPERSECOND) % 60;
  timespan->milliseconds = (ticks / TIMESPAN_NANOSPERMILLISECOND) % 1000;
  timespan->microseconds = (ticks / TIMESPAN_NANOSPERMICROSECOND) % 1000;
  timespan->nanoseconds = (ticks % 1000);
  timespan->__ticks = ticks;
  return ERROR_NONE;
}