![]() |
![]() |
![]() |
Zeitgeist Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
gint64 zeitgeist_timestamp_from_timeval (GTimeVal *timeval
); void zeitgeist_timestamp_to_timeval (gint64 timestamp
,GTimeVal *result
); gint64 zeitgeist_timestamp_from_now (void
); gint64 zeitgeist_timestamp_from_iso8601 (const gchar *datetime
); gchar * zeitgeist_timestamp_to_iso8601 (gint64 timestamp
); gint64 zeitgeist_timestamp_from_date (GDate *date
); gint64 zeitgeist_timestamp_from_dmy (GDateDay day
,GDateMonth month
,GDateYear year
); void zeitgeist_timestamp_to_date (gint64 timestamp
,GDate *result
); gint64 zeitgeist_timestamp_next_midnight (gint64 timestamp
); gint64 zeitgeist_timestamp_prev_midnight (gint64 timestamp
); #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
|
the (null) instance |
|
. time to convert. [in] |
Returns : |
number 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.
|
the (null) instance |
|
. to convert. [in] |
Returns : |
the equivalent GTimeVal instance. |
gint64 zeitgeist_timestamp_from_now (void
);
Return the current timestamp in milliseconds.
|
the (null) instance |
Returns : |
the timestamp for the current system time, in milliseconds since the Unix Epoch |
gint64 zeitgeist_timestamp_from_iso8601 (const gchar *datetime
);
Parse a timestamp from an ISO8601-encoded string.
|
the (null) instance |
|
. a string containing an ISO8601-conforming datetime. [in] |
Returns : |
the timestamp represented by the given string, or -1 if it can't be parsed |
gchar * zeitgeist_timestamp_to_iso8601 (gint64 timestamp
);
Convert a timestamp to a human-readable ISO8601 format
|
the (null) instance |
|
. a timestamp in milliseconds since the Unix Epoch. [in] |
Returns : |
a newly allocated string containing the ISO8601 version of the given timestamp |
gint64 zeitgeist_timestamp_from_date (GDate *date
);
Convert a GDate to a Zeitgeist timestamp
|
the (null) instance |
|
. the date to convert. [in] |
Returns : |
the given date expressed as a timestamp in milliseconds since the Epoch. The timestamp is guaranteed to be roudned off to the midnight of the given date. |
gint64 zeitgeist_timestamp_from_dmy (GDateDay day
,GDateMonth month
,GDateYear year
);
Convert a day, month, year tuple into a Zeitgeist timestamp
|
the (null) instance |
|
. the day of the month. [in] |
|
. the month of the year. [in] |
|
. the year. [in] |
Returns : |
the given date (rounded off to the midnight), expressed as a timestamp in milliseconds since the Epoch, or -1 in case the provided parameters don't constitute a valid date. |
void zeitgeist_timestamp_to_date (gint64 timestamp
,GDate *result
);
Write a timestamp to a GDate structure
|
the (null) instance |
|
. to convert. [in] |
Returns : |
GDate initialized to the given timestamp |
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.
|
the (null) instance |
|
. the Zeitgeist timestamp to find the next midnight for. [in] |
Returns : |
the timestamp for the next midnight after the given timestamp |
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.
|
the (null) instance |
|
. the Zeitgeist timestamp to find the previous midnight for. [in] |
Returns : |
the timestamp for the midnight just before the given timestamp |
#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)