common_util
Loading...
Searching...
No Matches
Enumerations | Functions
timeutil.h File Reference

Common time utilities. More...

#include <cstdint>

Go to the source code of this file.

Enumerations

enum class  cutl::timeunit { s , ms , us }
 Time unit enum. More...
 

Functions

uint64_t cutl::timestamp (timeunit unit)
 Get current timestamp.
 
uint64_t cutl::clocktime (timeunit unit)
 Get current clock time for monotone increment time.
 
uint64_t cutl::ms2s (uint64_t time)
 Convert time from milliseconds to seconds.
 
uint64_t cutl::us2s (uint64_t time)
 Convert time from microseconds to seconds.
 
uint64_t cutl::us2ms (uint64_t time)
 Convert time from seconds to milliseconds.
 
uint64_t cutl::s2ms (uint64_t time)
 Convert time from seconds to microseconds.
 
uint64_t cutl::s2us (uint64_t time)
 Convert time from seconds to microseconds.
 
uint64_t cutl::ms2us (uint64_t time)
 Convert time from milliseconds to microseconds.
 

Detailed Description

Common time utilities.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations.

Author
spencer.luo
Date
2024-05-13

Enumeration Type Documentation

◆ timeunit

enum class cutl::timeunit
strong

Time unit enum.

Enumerator

second

ms 

millisecond

us 

microsecond

Function Documentation

◆ clocktime()

uint64_t cutl::clocktime ( timeunit unit)

Get current clock time for monotone increment time.

Parameters
unittime unit
Returns
uint64_t clock time

◆ ms2s()

uint64_t cutl::ms2s ( uint64_t time)

Convert time from milliseconds to seconds.

Parameters
timetime in milliseconds
Returns
uint64_t time in seconds

◆ ms2us()

uint64_t cutl::ms2us ( uint64_t time)

Convert time from milliseconds to microseconds.

Parameters
timetime in milliseconds
Returns
uint64_t time in microseconds

◆ s2ms()

uint64_t cutl::s2ms ( uint64_t time)

Convert time from seconds to microseconds.

Parameters
timetime in seconds
Returns
uint64_t time in microseconds

◆ s2us()

uint64_t cutl::s2us ( uint64_t time)

Convert time from seconds to microseconds.

Parameters
timetime in seconds
Returns
uint64_t time in microseconds

◆ timestamp()

uint64_t cutl::timestamp ( timeunit unit)

Get current timestamp.

Parameters
unittime unit
Returns
uint64_t timestamp

◆ us2ms()

uint64_t cutl::us2ms ( uint64_t time)

Convert time from seconds to milliseconds.

Parameters
timetime in seconds
Returns
uint64_t time in milliseconds

◆ us2s()

uint64_t cutl::us2s ( uint64_t time)

Convert time from microseconds to seconds.

Parameters
timetime in microseconds
Returns
uint64_t time in seconds