You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
namespacesand
{
using point = uint64_t; // absolute time in milliseconds since Unix Epoch (1970/01/01 00:00:00.000 +00:00)using lapse = int64_t; // relative time in milliseconds between two timepoints; can be negative.using uint = unsignedint;
// sleep thread for specified milliseconds (at least)voidsleep( int64_t stamp );
// UTC absolute time, GMT timezone, local time and uptime since program epoch (in milliseconds)int64_tutc();
int64_tgmt();
int64_tnow();
int64_tuptime();
// advance/rewind all clocks specified milliseconds (useful for QA and testing purposes)voidshift( int64_t lapse );
// conversion to millisecondsint64_tnanoseconds( int64_t lapse );
int64_tmicroseconds( int64_t lapse );
int64_tmilliseconds( int64_t lapse );
int64_tseconds( int64_t lapse );
int64_tminutes( int64_t lapse );
int64_thours( int64_t lapse );
int64_tdays( int64_t lapse );
int64_tweeks( int64_t lapse );
// conversion from millisecondsint64_tas_nanoseconds( int64_t lapse );
int64_tas_microseconds( int64_t lapse );
int64_tas_milliseconds( int64_t lapse );
int64_tas_seconds( int64_t lapse );
int64_tas_minutes( int64_t lapse );
int64_tas_hours( int64_t lapse );
int64_tas_days( int64_t lapse );
int64_tas_weeks( int64_t lapse );
// calendarint64_tdate( int year, int month, int day );
int64_ttime( int hour, int minute, int second, int millis = 0 );
int64_tdatetime( int year, int month, int day, int hour, int minute, int second, int millis = 0 );
// extractionintyear( int64_t stamp );
intmonth( int64_t stamp );
intday( int64_t stamp );
inthour( int64_t stamp );
intminute( int64_t stamp );
intsecond( int64_t stamp );
intmillisecond( int64_t stamp );
// print
std::string format( int64_t stamp, const std::string &format = "yyyy-mm-dd HH:MM:SS.MS" );
std::string pretty( int64_t lapse );
// serialization
std::string str( int64_t stamp );
int64_tstr( const std::string &ymdhmsmtz );
classsand::timer dt;
// usage:// - int64_t nanoseconds_taken = dt.ns(); // (relative time)// - int64_t seconds_taken = dt.s(); // (relative time)// - int64_t milliseconds_taken = dt.ms(); // (relative time)// - see also .reset();classsand::chrono chr(3.5); // in seconds// usage:// - chr.t() -> [0..1] (normalized floating time)// - see also .reset();classsand::looper lp(3.5); // in seconds (similar to sand::chrono but will loop over and over)// usage:// - lp.t() -> [0..1][...] (normalized floating time)// - see also .reset();
}
Special notes
g++ users: both -std=c++11 and -lrt may be required when compiling sand.cpp
Changelog
v2.0.0 (2015/09/26)
A step forward towards portability and determinism.