Top |
#define | ZEITGEIST_TIMESTAMP_SECOND |
#define | ZEITGEIST_TIMESTAMP_MINUTE |
#define | ZEITGEIST_TIMESTAMP_HOUR |
#define | ZEITGEIST_TIMESTAMP_DAY |
#define | ZEITGEIST_TIMESTAMP_WEEK |
#define | ZEITGEIST_TIMESTAMP_YEAR |
include: zeitgeist.h
A suite of convenience functions for dealing with timestamps and dates.
Zeitgeist timestamps are represented as gint64s with the number of milliseconds since the Unix Epoch.
gint64
zeitgeist_timestamp_from_timeval (GTimeVal *timeval
);
Convert a GTimeVal to an amount of milliseconds since the Unix Epoch
void zeitgeist_timestamp_to_timeval (gint64 timestamp
,GTimeVal *result
);
Write a Zeitgeist timestamp to a GTimeVal instance. Note that Zeitgeist uses only a millisecond resolution, whereas GTimeVal has microsecond resolution. This means that the lower three digits of tv.tv_usec
will always be 0.
gint64
zeitgeist_timestamp_from_now (void
);
Return the current timestamp in milliseconds.
gint64
zeitgeist_timestamp_from_iso8601 (const gchar *datetime
);
Parse a timestamp from an ISO8601-encoded string.
gchar *
zeitgeist_timestamp_to_iso8601 (gint64 timestamp
);
Convert a timestamp to a human-readable ISO8601 format
gint64
zeitgeist_timestamp_from_date (GDate *date
);
Convert a GDate to a Zeitgeist timestamp
gint64 zeitgeist_timestamp_from_dmy (GDateDay day
,GDateMonth month
,GDateYear year
);
Convert a day, month, year tuple into a Zeitgeist timestamp
void zeitgeist_timestamp_to_date (gint64 timestamp
,GDate *result
);
Write a timestamp to a GDate structure
gint64
zeitgeist_timestamp_next_midnight (gint64 timestamp
);
Calculate the timestamp for the next midnight after the given timestamp.
If is is already midnight (down to the millisecond), this method will return the value for the next midnight. In other words, you can call this method recursively in order to iterate, forwards in time, over midnights.
gint64
zeitgeist_timestamp_prev_midnight (gint64 timestamp
);
Calculate the timestamp for the midnight just before the given timestamp.
If is is already midnight (down to the millisecond), this method will return the value for the previous midnight. In other words, you can call this method recursively in order to iterate, backwards in time, over midnights.
#define ZEITGEIST_TIMESTAMP_SECOND ((gint64) 1000)
A second represented as a Zeitgeist timestamp (ie. 1000ms)
#define ZEITGEIST_TIMESTAMP_MINUTE ((gint64) 60000)
A minute represented as a Zeitgeist timestamp (ie. 60000ms)
#define ZEITGEIST_TIMESTAMP_HOUR ((gint64) 3600000)
An hour represented as a Zeitgeist timestamp (ie. 3600000ms)
#define ZEITGEIST_TIMESTAMP_DAY ((gint64) 86400000)
A day represented as a Zeitgeist timestamp (ie. 86400000ms)
#define ZEITGEIST_TIMESTAMP_WEEK ((gint64) 604800000)
A week represented as a Zeitgeist timestamp (ie. 604800000ms)