feisty meow concerns codebase  2.140
timely::clock_time Class Reference

A specific point in time as represented by a 24 hour clock. More...

#include <earth_time.h>

Inheritance diagram for timely::clock_time:
Collaboration diagram for timely::clock_time:

Public Types

enum  time_formats {
  MERIDIAN = 0x1 , MILITARY = 0x2 , NO_AM_PM = 0x4 , SECONDS = 0x8 ,
  MILLISECONDS = 0x10
}
 An enumeration of time formatting modes used when printing the time. More...
 

Public Member Functions

 clock_time (time_number h=0, time_number m=0, time_number s=0, time_number ms=0, time_number us=0)
 Constructs a clock_time object given all the parts. More...
 
 ~clock_time ()
 
int packed_size () const
 Estimates the space needed for the packed structure. More...
 
virtual void pack (basis::byte_array &packed_form) const
 Packs a clock time into an array of bytes. More...
 
virtual bool unpack (basis::byte_array &packed_form)
 Unpacks a clock time from an array of bytes. More...
 
bool operator< (const clock_time &to_compare) const
 Returns true if this clock_time is earlier than "to_compare". More...
 
bool operator== (const clock_time &to_compare) const
 Returns true if this clock_time is equal to "to_compare". More...
 
basis::astring text_form (int how=MERIDIAN) const
 Prints the clock_time according to "how". More...
 
void text_form (basis::astring &to_stuff, int how=MERIDIAN) const
 Prints the time into "to_stuff" given "how". More...
 

Static Public Member Functions

static time_number normalize (clock_time &to_fix)
 

Public Attributes

time_number hour
 The hour represented in military time: 0 through 23. More...
 
time_number minute
 The number of minutes after the hour. More...
 
time_number second
 The number of seconds after the current minute. More...
 
time_number millisecond
 The number of milliseconds elapsed in this second. More...
 
time_number microsecond
 Number of microseconds elapsed in this millisecond. More...
 

Detailed Description

A specific point in time as represented by a 24 hour clock.

Definition at line 84 of file earth_time.h.

Member Enumeration Documentation

◆ time_formats

An enumeration of time formatting modes used when printing the time.

Enumerator
MERIDIAN 

default: uses 12 hour with AM/PM and no seconds.

MILITARY 

use military 24 hour time.

NO_AM_PM 

use 12 hour time but don't include AM/PM.

SECONDS 

include the number of seconds as a third field.

MILLISECONDS 

milliseconds are fourth field (after secs).

Definition at line 112 of file earth_time.h.

Constructor & Destructor Documentation

◆ clock_time()

timely::clock_time::clock_time ( time_number  h = 0,
time_number  m = 0,
time_number  s = 0,
time_number  ms = 0,
time_number  us = 0 
)
inline

Constructs a clock_time object given all the parts.

Definition at line 94 of file earth_time.h.

◆ ~clock_time()

timely::clock_time::~clock_time ( )
inline

Definition at line 97 of file earth_time.h.

Member Function Documentation

◆ normalize()

time_number timely::clock_time::normalize ( clock_time to_fix)
static

Definition at line 144 of file earth_time.cpp.

References hour, limit_value, microsecond, millisecond, minute, and second.

◆ operator<()

bool timely::clock_time::operator< ( const clock_time to_compare) const

Returns true if this clock_time is earlier than "to_compare".

Definition at line 86 of file earth_time.cpp.

References EASY_LT, hour, microsecond, millisecond, minute, and second.

◆ operator==()

bool timely::clock_time::operator== ( const clock_time to_compare) const

Returns true if this clock_time is equal to "to_compare".

Definition at line 96 of file earth_time.cpp.

References hour, microsecond, millisecond, minute, and second.

◆ pack()

void timely::clock_time::pack ( basis::byte_array packed_form) const
virtual

Packs a clock time into an array of bytes.

Implements basis::packable.

Reimplemented in timely::time_locus.

Definition at line 63 of file earth_time.cpp.

References basis::attach().

◆ packed_size()

int timely::clock_time::packed_size ( ) const
inlinevirtual

Estimates the space needed for the packed structure.

Implements basis::packable.

Reimplemented in timely::time_locus.

Definition at line 99 of file earth_time.h.

References structures::PACKED_SIZE_INT32.

Referenced by timely::time_locus::packed_size().

◆ text_form() [1/2]

void timely::clock_time::text_form ( basis::astring to_stuff,
int  how = MERIDIAN 
) const

Prints the time into "to_stuff" given "how".

note that "to_stuff" will be appended to; the existing contents are retained.

Definition at line 112 of file earth_time.cpp.

◆ text_form() [2/2]

astring timely::clock_time::text_form ( int  how = MERIDIAN) const

Prints the clock_time according to "how".

"how" is a combination of time_formats.

Definition at line 105 of file earth_time.cpp.

◆ unpack()

bool timely::clock_time::unpack ( basis::byte_array packed_form)
virtual

Unpacks a clock time from an array of bytes.

Implements basis::packable.

Reimplemented in timely::time_locus.

Definition at line 72 of file earth_time.cpp.

References basis::detach().

Member Data Documentation

◆ hour

time_number timely::clock_time::hour

The hour represented in military time: 0 through 23.

Definition at line 87 of file earth_time.h.

Referenced by timely::convert(), normalize(), operator<(), operator==(), and timely::time_control::set_time().

◆ microsecond

time_number timely::clock_time::microsecond

Number of microseconds elapsed in this millisecond.

Definition at line 91 of file earth_time.h.

Referenced by timely::convert(), normalize(), operator<(), and operator==().

◆ millisecond

time_number timely::clock_time::millisecond

The number of milliseconds elapsed in this second.

Definition at line 90 of file earth_time.h.

Referenced by timely::convert(), normalize(), operator<(), and operator==().

◆ minute

time_number timely::clock_time::minute

The number of minutes after the hour.

Definition at line 88 of file earth_time.h.

Referenced by timely::convert(), normalize(), operator<(), operator==(), and timely::time_control::set_time().

◆ second

time_number timely::clock_time::second

The number of seconds after the current minute.

Definition at line 89 of file earth_time.h.

Referenced by timely::convert(), normalize(), operator<(), operator==(), and timely::time_control::set_time().


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