ml_time.h
Functions
Name | |
---|---|
MLResult | MLTimeConvertMLTimeToSystemTime(MLTime ml_time, struct timespec * out_timespec_time) Converts timestamps from MLTime to system time. |
MLResult | MLTimeConvertSystemTimeToMLTime(const struct timespec timespec_time, MLTime out_ml_time) Converts timestamps from system time to MLTime. |
Functions Documentation
MLTimeConvertMLTimeToSystemTime
MLResult MLTimeConvertMLTimeToSystemTime(
MLTime ml_time,
struct timespec * out_timespec_time
)
Converts timestamps from MLTime to system time.
Parameters
MLTime | ml_time | Timestamp received from elsewhere in the ML system. |
struct timespec * | out_timespec_time | Pointer to a converted equivalent timestamp as if received from clock_gettime using CLOCK_MONOTONIC. |
Returns
MLResult | MLResult_Ok | Successfully converted timestamp. |
MLResult | MLResult_InvalidParam | NULL passed for timespec_time. |
MLResult | MLResult_UnspecifiedFailure | Failed to convert timestamp with unknown error. |
Required Permissions:
- None
See MLTime for more details. System time is equivalent to the systems monotonic clock. This can be used to calculate duration between two MLTime values by converting them both to a timespec and subtracting the subsequent values.
API Level:
- 20
MLTimeConvertSystemTimeToMLTime
MLResult MLTimeConvertSystemTimeToMLTime(
const struct timespec * timespec_time,
MLTime * out_ml_time
)
Converts timestamps from system time to MLTime.
Parameters
const struct timespec * | timespec_time | System clock timestamp as received from clock_gettime using CLOCK_MONOTONIC. |
MLTime * | out_ml_time | Pointer to system timestamp equivalent in MLTime. |
Returns
MLResult | MLResult_Ok | Successfully converted timestamp. |
MLResult | MLResult_InvalidParam | NULL passed for ml_time. |
MLResult | MLResult_UnspecifiedFailure | Failed to convert timespec with unknown error. |
Required Permissions:
- None
See MLTime for more details. System time is equivalent to the systems monotonic clock.
API Level:
- 20
Source code
// %BANNER_BEGIN%
// ---------------------------------------------------------------------
// %COPYRIGHT_BEGIN%
// Copyright (c) 2022 Magic Leap, Inc. All Rights Reserved.
// Use of this file is governed by the Software License Agreement,
// located here: https://www.magicleap.com/software-license-agreement-ml2
// Terms and conditions applicable to third-party materials accompanying
// this distribution may also be found in the top-level NOTICE file
// appearing herein.
// %COPYRIGHT_END%
// ---------------------------------------------------------------------
// %BANNER_END%
#pragma once
#include <time.h>
#include "ml_api.h"
#include "ml_types.h"
ML_EXTERN_C_BEGIN
ML_API MLResult ML_CALL MLTimeConvertMLTimeToSystemTime(MLTime ml_time, struct timespec *out_timespec_time);
ML_API MLResult ML_CALL MLTimeConvertSystemTimeToMLTime(const struct timespec *timespec_time, MLTime *out_ml_time);
ML_EXTERN_C_END