18 #ifndef SHEVEK_TIME_HH
19 #define SHEVEK_TIME_HH
27 sigc::connection schedule (sigc::slot0 <void> callback,
int prio = Glib::PRIORITY_HIGH_IDLE, Glib::RefPtr <Glib::MainContext> context = Glib::MainContext::get_default () );
30 typedef int64_t timetype;
41 unsigned m_nanoseconds;
42 static bool l_schedule (sigc::slot0 <void> callback);
45 sigc::connection
schedule (sigc::slot0 <void> callback,
int prio,
46 Glib::RefPtr <Glib::MainContext> context);
47 static unsigned s_digits;
58 absolute_time (
unsigned years,
unsigned months,
unsigned days,
unsigned hours,
unsigned minutes,
unsigned seconds,
unsigned nanoseconds = 0);
67 static absolute_time create_from_local (
unsigned years,
unsigned months,
unsigned days,
unsigned hours,
unsigned minutes,
unsigned seconds,
unsigned nanoseconds = 0);
123 unsigned hour ()
const;
125 unsigned days ()
const;
127 unsigned day ()
const;
131 unsigned month ()
const;
133 unsigned year ()
const;
135 timetype
total ()
const;
137 sigc::connection
schedule (sigc::slot0 <void> callback, Glib::RefPtr <Glib::MainContext> context = Glib::MainContext::get_default ());
149 static unsigned s_digits;
211 unsigned hours ()
const;
213 unsigned days ()
const;
217 timetype
total ()
const;
225 std::istream &operator>> (std::istream &s,
absolute_time &t);
227 std::istream &operator>> (std::istream &s,
relative_time &t);
relative_time operator/(float c) const
Scale an interval.
relative_time & operator/=(float c)
Scale the interval.
relative_time & operator%=(relative_time that)
Modulo.
static unsigned get_digits()
Get the number of digits which is used when printing.
bool operator==(absolute_time that) const
Compare two moments.
unsigned local_weekday() const
Get the day of the week in local time, range 0-6 where 0 means sunday.
bool operator!=(absolute_time that) const
Compare two moments.
unsigned local_minute() const
Get the minutes in local time.
relative_time()
The default constructor creates an interval of 0.
relative_time operator*(float c) const
Scale an interval.
timetype total() const
Total number of seconds, as encoded.
Time interval.
Definition: time.hh:143
friend std::ostream & operator<<(std::ostream &s, relative_time t)
Write the interval to a std::ostream.
relative_time operator+(relative_time that) const
Add two intervals.
absolute_time()
Create a new absolute_time containing the current time.
unsigned local_second() const
Get the seconds in local time.
bool operator==(relative_time that) const
static void set_digits(unsigned num)
Set number of digits to use when printing (for fractions of seconds).
absolute_time operator+(relative_time that) const
Add an interval to this moment.
relative_time operator-() const
Negate an interval.
unsigned seconds() const
Number of seconds.
bool operator>(absolute_time that) const
Compare two moments.
bool operator<=(absolute_time that) const
Compare two moments.
bool operator<=(relative_time that) const
Compare with another interval.
friend sigc::connection schedule(sigc::slot0< void > callback, int prio, Glib::RefPtr< Glib::MainContext > context)
Schedule a callback for when the main loop has time.
bool operator<(absolute_time that) const
Compare two moments.
relative_time & operator+=(relative_time that)
Add an interval.
unsigned hour() const
Get the hour in UTC.
unsigned local_month() const
Get the month in local time, range 1-12.
relative_time & operator*=(float c)
Scale the interval.
static void set_digits(unsigned num)
Set number of digits to use when printing (for fractions of seconds)
bool operator>=(absolute_time that) const
Compare two moments.
friend std::ostream & operator<<(std::ostream &s, absolute_time t)
Write the time to a std::ostream.
absolute_time operator-(relative_time that) const
Subtract an interval from this moment.
relative_time & operator-=(relative_time that)
Subtract an interval.
unsigned local_days() const
Get the day of the year in local time, range 0-365.
static unsigned get_digits()
Get the number of digits that is used when printing.
unsigned local_year() const
Get the year in local time.
unsigned days() const
Number of days.
unsigned month() const
Get the month in UTC, range 1-12.
bool operator>=(relative_time that) const
Compare with another interval.
unsigned year() const
Get the year in UTC.
The absolute_time class stores a date and time.
Definition: time.hh:36
bool operator!=(relative_time that) const
relative_time operator%(relative_time that) const
Modulo operator for two intervals.
unsigned minutes() const
Number of minutes.
unsigned nanoseconds() const
Number of nanoseconds.
static absolute_time create_from_local(unsigned years, unsigned months, unsigned days, unsigned hours, unsigned minutes, unsigned seconds, unsigned nanoseconds=0)
Semi-constructor which creates a new absolute_time given a date in local time.
unsigned hours() const
Number of hours.
unsigned local_day() const
Get the day of the month in local time, range 1-31.
unsigned second() const
Get the seconds in UTC.
unsigned days() const
Get the day of the year in UTC, range 0-365.
bool isnegative() const
Is this a negative interval?
bool operator<(relative_time that) const
Compare with another interval.
absolute_time & operator-=(relative_time that)
Subtract an interval from this moment.
bool operator>(relative_time that) const
Compare with another interval.
timetype total() const
Total number of seconds since january 1970, as encoded.
absolute_time & operator+=(relative_time that)
Add an interval to this moment.
unsigned minute() const
Get the minutes in UTC.
unsigned weekday() const
Get the day of the week in UTC, range 0-6 where 0 means sunday.
unsigned local_hour() const
Get the hour in local time.
unsigned day() const
Get the day of the month in UTC, range 1-31.
unsigned nanoseconds() const
Get the nanoseconds.