rcolyer.net
RC Lib  Version 202403231100
Public Member Functions | Static Public Member Functions | List of all members
RC::Time Class Reference

Accesses and formats the system date and time, and provides high precision timing. More...

#include <RTime.h>

Public Member Functions

void Start ()
 Start the timer.
 
 Time ()
 Default constructor. Starts the timer.
 
f64 SinceStart ()
 Returns seconds since start in real time.
 
f64 ProcSinceStart ()
 Returns seconds since start in process time.
 

Static Public Member Functions

static f64 Get ()
 Returns seconds since 1970-01-01 epoch to a precision between 100 nanoseconds and 1 microsecond.
 
static f64 Get (time_t tt)
 Converts a time_t value into seconds from the 1970-01-01 epoch.
 
static f64 Get (struct tm tmval)
 Returns the seconds from the 1970-01-01 epoch for tmval.
 
static f64 Get_UTC (struct tm tmval)
 Given a UTC struct tm, returns the seconds since epoch portably.
 
static f64 GetPrecision ()
 Empirically determines the precision of Get(), and stores this value for future calls to this. More...
 
static i32 GetTimezone ()
 Returns the number of seconds offset from UTC.
 
static Data1D< i32GetTimezoneData ()
 Returns { hours, min, sec } offset from UTC.
 
static struct tm Local2UTC (struct tm tmval)
 Returns the local time given UTC time tmval.
 
static struct tm UTC2Local (struct tm tmval)
 Returns the UTC time given local time tmval.
 
static time_t Get_time_t ()
 Returns time_t as number of seconds since 1970-01-01 00:00:00 UTC.
 
static time_t Get_time_t (f64 val)
 Portably converts val as seconds since 1970-01-01 epoch to time_t.
 
static time_t Get_time_t (struct tm tmval)
 Converts tmval in local timezone to time_t.
 
static time_t Get_time_t_UTC (struct tm tmval)
 Converts tmval in UTC to time_t.
 
static void Normalize (struct tm &tmval)
 Normalizes the input tmval.
 
static struct tm Get_tm ()
 Provides a struct tm in the local timezone for the current time.
 
static struct tm Get_tm (time_t tt)
 Provides a struct tm in the current timezone for the given time_t.
 
static struct tm Get_tm (f64 val)
 Provides a struct tm in the local timezone for val seconds from the 1970-01-01 epoch.
 
static struct tm Get_tm_UTC ()
 Provides a struct tm in UTC for the current time.
 
static struct tm Get_tm_UTC (time_t tt)
 Provides a struct tm in UTC for the given time_t.
 
static struct tm Get_tm_UTC (f64 val)
 Provides a struct tm in the local timezone for val seconds from the 1970-01-01 epoch.
 
static struct tm Get_tm (struct tm tmval)
 Returns a normalized struct tm.
 
static RStr GetStr ()
 Provides the current time in the format "Fri Aug 1 17:05:25 2014".
 
static RStr GetStr (struct tm tmval)
 Provides the time in the format "Fri Aug 1 17:05:25 2014".
 
static RStr GetStr_UTC ()
 Provides the UTC time in the format "Fri Aug 1 17:05:25 2014".
 
static RStr GetStr (const RStr &format)
 Provides the local time as a string with the format processed by strftime.
 
static RStr GetStr (const RStr &format, struct tm tmval)
 Provides the tmval as a string with the format processed by strftime.
 
static RStr GetStr_UTC (const RStr &format)
 Provides the UTC time as a string with the format processed by strftime.
 
static RStr GetDate ()
 Returns a local date string formatted like "2011-07-28".
 
static RStr GetDate (struct tm tmval)
 Returns a date string for tmval formatted like "2011-07-28".
 
static RStr GetDate_UTC ()
 Returns a UTC date string formatted like "2011-07-28".
 
static RStr GetTime ()
 Returns a local time string formatted like "19:49:18".
 
static RStr GetTime (struct tm tmval)
 Returns a time string for tmval formatted like "19:49:18".
 
static RStr GetTime_UTC ()
 Returns a UTC time string formatted like "19:49:18".
 
static RStr GetDateTime ()
 Returns a local date-time string formatted like "2011-07-28_19-49-18", which is suitable for filenames.
 
static RStr GetDateTime (struct tm tmval)
 Returns a date-time string from tmval formatted like "2011-07-28_19-49-18", which is suitable for filenames.
 
static RStr GetDateTime_UTC ()
 Returns a UTC date-time string formatted like "2011-07-28_19-49-18", which is suitable for filenames.
 
static struct tm ParseDate (const RStr &date, struct tm tmval)
 Parses a date string like 2011-07-28, 2011-7-28, 07-28, 7-28, or "/" instead of "-", into base tmval.
 
static struct tm ParseDate (const RStr &date)
 Parses a date string like 2011-07-28, 2011-7-28, 07-28, 7-28, or "/" instead of "-", into base local time.
 
static struct tm ParseDate_UTC (const RStr &date)
 Parses a date string like 2011-07-28, 2011-7-28, 07-28, 7-28, or "/" instead of "-", into base UTC time.
 
static struct tm ParseTime (const RStr &date, struct tm tmval)
 Parses a time string like 19:49:18, 19:49, or "-" instead of ":", into base tmval.
 
static struct tm ParseTime (const RStr &date)
 Parses a time string like 19:49:18, 19:49, or "-" instead of ":", into base local time.
 
static struct tm ParseTime_UTC (const RStr &date)
 Parses a time string like 19:49:18, 19:49, or "-" instead of ":", into base UTC time.
 
static struct tm ParseDateTime (const RStr &date, struct tm tmval)
 Parses a string like ParseDate and ParseTime separated by "_" or " ", into base tmval.
 
static struct tm ParseDateTime (const RStr &date)
 Parses a string like ParseDate and ParseTime separated by "_" or " ", into base local time.
 
static struct tm ParseDateTime_UTC (const RStr &date)
 Parses a string like ParseDate and ParseTime separated by "_" or " ", into base UTC time.
 
static void Sleep (f64 seconds)
 Sleeps for a floating point number of seconds, with sub-second precision to the limit of the system.
 

Detailed Description

Accesses and formats the system date and time, and provides high precision timing.

Member Function Documentation

◆ GetPrecision()

static f64 RC::Time::GetPrecision ( )
inlinestatic

Empirically determines the precision of Get(), and stores this value for future calls to this.

Returns
The smallest amount by which Get() can increment.

The documentation for this class was generated from the following file:
email address
— (c) 2015