26 #if ! defined (octave_oct_time_h)
27 #define octave_oct_time_h 1
29 #include "octave-config.h"
43 return (
static_cast<double> (sec) +
static_cast<double> (usec) / 1.0e6);
59 : ot_unix_time (0), ot_usec (0) { stamp (); }
62 : ot_unix_time (t), ot_usec (0) { }
65 : ot_unix_time (t), ot_usec ()
72 extra = (us -
rem) / 1000000;
78 extra = - (1 + (us -
rem) / 1000000);
79 rem = 1000000 - us % 1000000;
83 ot_unix_time += extra;
91 : ot_unix_time (ot.ot_unix_time), ot_usec (ot.ot_usec) { }
110 return as_double (ot_unix_time, ot_usec);
115 long usec (
void)
const {
return ot_usec; }
117 std::string ctime (
void)
const;
158 return (t1 < t2 || t1 == t2);
177 return (t1 > t2 || t1 == t2);
194 : m_usec (0), m_sec (0), m_min (0), m_hour (0),
195 m_mday (0), m_mon (0), m_year (0), m_wday (0),
196 m_yday (0), m_isdst (0), m_gmtoff (0), m_zone (
"unknown")
200 : m_usec (tm.m_usec), m_sec (tm.m_sec), m_min (tm.m_min),
201 m_hour (tm.m_hour), m_mday (tm.m_mday), m_mon (tm.m_mon),
202 m_year (tm.m_year), m_wday (tm.m_wday), m_yday (tm.m_yday),
203 m_isdst (tm.m_isdst), m_gmtoff (tm.m_gmtoff), m_zone (tm.m_zone)
229 int usec (
void)
const {
return m_usec; }
230 int sec (
void)
const {
return m_sec; }
231 int min (
void)
const {
return m_min; }
232 int hour (
void)
const {
return m_hour; }
233 int mday (
void)
const {
return m_mday; }
234 int mon (
void)
const {
return m_mon; }
235 int year (
void)
const {
return m_year; }
236 int wday (
void)
const {
return m_wday; }
237 int yday (
void)
const {
return m_yday; }
238 int isdst (
void)
const {
return m_isdst; }
239 long gmtoff (
void)
const {
return m_gmtoff; }
240 std::string
zone (
void)
const {
return m_zone; }
253 base_tm& zone (
const std::string& s);
255 std::string strftime (
const std::string& fmt)
const;
258 {
return strftime (
"%a %b %d %H:%M:%S %Y\n"); }
326 void init (
const time& ot);
351 void init (
const time& ot);
360 strptime (
const std::string& str,
const std::string& fmt)
367 :
base_tm (s), nchars (s.nchars) { }
384 void init (
const std::string& str,
const std::string& fmt);
396 : m_usr_sec (0), m_sys_sec (0), m_usr_usec (0), m_sys_usec (0)
402 : m_usr_sec (tm.m_usr_sec), m_sys_sec (tm.m_sys_sec),
403 m_usr_usec (tm.m_usr_usec), m_sys_usec (tm.m_sys_usec)
423 return as_double (m_usr_sec, m_usr_usec);
428 return as_double (m_sys_sec, m_sys_usec);
445 cpu_time (time_t usr_sec, time_t sys_sec,
long usr_usec,
long sys_usec)
446 : m_usr_sec (usr_sec), m_sys_sec (sys_sec),
447 m_usr_usec (usr_usec), m_sys_usec (sys_usec)
457 : m_cpu (), m_maxrss (0), m_ixrss (0), m_idrss (0),
458 m_isrss (0), m_minflt (0), m_majflt (0), m_nswap (0),
459 m_inblock (0), m_oublock (0), m_msgsnd (0), m_msgrcv (0),
460 m_nsignals (0), m_nvcsw (0), m_nivcsw (0)
466 : m_cpu (ru.m_cpu), m_maxrss (ru.m_maxrss),
467 m_ixrss (ru.m_ixrss), m_idrss (ru.m_idrss),
468 m_isrss (ru.m_isrss), m_minflt (ru.m_minflt),
469 m_majflt (ru.m_majflt), m_nswap (ru.m_nswap),
470 m_inblock (ru.m_inblock), m_oublock (ru.m_oublock),
471 m_msgsnd (ru.m_msgsnd), m_msgrcv (ru.m_msgrcv),
472 m_nsignals (ru.m_nsignals), m_nvcsw (ru.m_nvcsw),
473 m_nivcsw (ru.m_nivcsw)
505 long maxrss (
void)
const {
return m_maxrss; }
506 long ixrss (
void)
const {
return m_ixrss; }
507 long idrss (
void)
const {
return m_idrss; }
508 long isrss (
void)
const {
return m_isrss; }
509 long minflt (
void)
const {
return m_minflt; }
510 long majflt (
void)
const {
return m_majflt; }
511 long nswap (
void)
const {
return m_nswap; }
512 long inblock (
void)
const {
return m_inblock; }
513 long oublock (
void)
const {
return m_oublock; }
514 long msgsnd (
void)
const {
return m_msgsnd; }
515 long msgrcv (
void)
const {
return m_msgrcv; }
517 long nvcsw (
void)
const {
return m_nvcsw; }
518 long nivcsw (
void)
const {
return m_nivcsw; }
charNDArray min(char d, const charNDArray &m)
std::string zone(void) const
base_tm(const base_tm &tm)
base_tm & operator=(const base_tm &tm)
virtual ~base_tm(void)=default
std::string asctime(void) const
long system_usec(void) const
cpu_time(const cpu_time &tm)
time_t system_sec(void) const
double system(void) const
long user_usec(void) const
time_t user_sec(void) const
cpu_time(time_t usr_sec, time_t sys_sec, long usr_usec, long sys_usec)
localtime(const time &ot)
localtime(const localtime &t)
long nsignals(void) const
resource_usage(const resource_usage &ru)
strptime(const strptime &s)
int characters_converted(void) const
strptime(const std::string &str, const std::string &fmt)
double double_value(void) const
time_t unix_time(void) const
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
bool operator!=(const time &t1, const time &t2)
bool operator==(const time &t1, const time &t2)
std::ostream & operator<<(std::ostream &os, const time &ot)
bool operator<=(const time &t1, const time &t2)
bool operator>=(const time &t1, const time &t2)
bool operator<(const time &t1, const time &t2)
bool operator>(const time &t1, const time &t2)
time operator+(const time &t1, const time &t2)
octave_int< T > rem(const octave_int< T > &x, const octave_int< T > &y)
static double as_double(time_t sec, long usec)