Spicy
Classes | Public Member Functions | List of all members
hilti::rt::Time Class Reference

#include <time.h>

Classes

struct  NanosecondTag
 
struct  SecondTag
 

Public Member Functions

 Time ()=default
 
 Time (hilti::rt::integer::safe< uint64_t > nsecs, NanosecondTag)
 
 Time (double secs, SecondTag)
 
 Time (const Time &)=default
 
 Time (Time &&) noexcept=default
 
Timeoperator= (const Time &)=default
 
Timeoperator= (Time &&) noexcept=default
 
double seconds () const
 
uint64_t nanoseconds () const
 
bool operator== (const Time &other) const
 
bool operator!= (const Time &other) const
 
bool operator< (const Time &other) const
 
bool operator<= (const Time &other) const
 
bool operator> (const Time &other) const
 
bool operator>= (const Time &other) const
 
Time operator+ (const Interval &other) const
 
Time operator- (const Interval &other) const
 
Interval operator- (const Time &other) const
 
 operator std::string () const
 

Detailed Description

Represents HILTI's time type. Intervals are stored as nanoseconds resolution as intervals since the UNIX epoch.

Constructor & Destructor Documentation

◆ Time() [1/3]

hilti::rt::Time::Time ( )
default

Constructs null Time value.

◆ Time() [2/3]

hilti::rt::Time::Time ( hilti::rt::integer::safe< uint64_t >  nsecs,
NanosecondTag   
)
inlineexplicit

Constructs an interval from an unsigned integer value.

Parameters
nsecsinterval in nanoseconds.

◆ Time() [3/3]

hilti::rt::Time::Time ( double  secs,
SecondTag   
)
inlineexplicit

Constructs a time from a double value.

Parameters
secsseconds since the UNIX epoch.
Exceptions
OutOfRangeif secs cannot be represented with the internal resolution

Member Function Documentation

◆ nanoseconds()

uint64_t hilti::rt::Time::nanoseconds ( ) const
inline

Returns nanoseconds since epoch.

◆ operator std::string()

Time::operator std::string ( ) const

Returns a human-readable representation of the time.

◆ seconds()

double hilti::rt::Time::seconds ( ) const
inline

Returns a UNIX timestamp.


The documentation for this class was generated from the following files: