31 #ifdef DEBUG_TIME_STAMP
32 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
36 using namespace basis;
40 static mutex &__uptime_synchronizer() {
41 static mutex uptiming_syncher;
42 return uptiming_syncher;
49 the_time.
text_form_long(to_return, clock_time::MILITARY | clock_time::MILLISECONDS);
50 if (add_space) to_return +=
" ";
54 time_stamp::time_stamp() : c_stamp(0) { fill_in_time(); }
57 : c_stamp(0) {
reset(offset); }
67 stump -= get_time_now();
88 bool did_hours =
false;
90 to_return +=
astring(astring::SPRINTF,
"%uh:", hours);
93 if (minutes || did_hours)
94 to_return +=
astring(astring::SPRINTF,
"%02um:", minutes);
95 to_return +=
astring(astring::SPRINTF,
"%02us.%03u", seconds, milliseconds);
97 if (past) to_return +=
" ago";
98 else to_return +=
" from now";
103 void time_stamp::fill_in_time()
127 static int __rollovers = 0;
132 if (ticks_up < __last_ticks) {
136 __last_ticks = ticks_up;
148 time_out.tv_usec = 0;
149 #ifdef DEBUG_TIME_STAMP
150 LOG(
"no duration specified");
154 time_out.tv_sec = duration / 1000;
156 duration -= time_out.tv_sec * 1000;
158 time_out.tv_usec = duration * 1000;
160 #ifdef DEBUG_TIME_STAMP
161 LOG(
a_sprintf(
"duration of %d ms went to %d sec and %d usec.", duration,
162 time_out.tv_sec, time_out.tv_usec));
a_sprintf is a specialization of astring that provides printf style support.
Provides a dynamically resizable ASCII character string.
auto_synchronizer simplifies concurrent code by automatically unlocking.
An object that represents a particular point in time.
basis::astring text_form_long(int t=clock_time::MERIDIAN, int d=day_in_year::SHORT_MONTH, int y=LONG_YEAR) const
basis::astring text_form(stamp_display_style style=STAMP_RELATIVE) const
returns a simple textual representation of the time_stamp.
void reset()
sets the stamp time back to now.
static double rolling_uptime()
give the OS uptime in a more durable form that handles rollovers.
time_stamp()
creates a time_stamp containing the current time.
double time_representation
the representation of time for this universe, measured in milliseconds.
static void fill_timeval_ms(timeval &time_point, int milliseconds)
returns a timeval system object that represents the "milliseconds".
#define MAXINT32
Maximum 32-bit integer value.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
The guards collection helps in testing preconditions and reporting errors.
const int SECOND_ms
Number of milliseconds in a second.
unsigned int un_int
Abbreviated name for unsigned integers.
bool negative(const type &a)
negative returns true if "a" is less than zero.
type absolute_value(type a)
Returns a if a is non-negative, and returns -a otherwise.
A logger that sends to the console screen using the standard output device.
time_locus now()
returns our current locus in the time continuum.
const double __rollover_point
Aids in achievement of platform independence.