comparison src/util.h @ 13119:fcde3faa1f57

[gaim-migrate @ 15481] This adds support for displaying log timestamps in their original timezone. If your OS's definition of struct tm sucks, then the log timestamps will show up in your local timezone, but converted, so the time is accurate. Yay! Anyway, this all works, as I've renamed lots of my log files locally, but currently, there's no code to save new logs in this name format. That's held up on a portability issue and backwards compatibility issue. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sat, 04 Feb 2006 20:55:52 +0000
parents e1e5462b7d81
children 4bb701a8736f
comparison
equal deleted inserted replaced
13118:8855973b487b 13119:fcde3faa1f57
213 /** 213 /**
214 * Formats a time into the specified format. 214 * Formats a time into the specified format.
215 * 215 *
216 * This is essentially strftime(), but it has a static buffer 216 * This is essentially strftime(), but it has a static buffer
217 * and handles the UTF-8 conversion for the caller. 217 * and handles the UTF-8 conversion for the caller.
218 *
219 * @param format The format string
220 * @param tm The time to format, or @c NULL to use the current local time
221 *
222 * @return The formatted time, in UTF-8.
218 */ 223 */
219 const char *gaim_utf8_strftime(const char *format, const struct tm *tm); 224 const char *gaim_utf8_strftime(const char *format, const struct tm *tm);
220 225
221 /** 226 /**
222 * Formats a time into the user's preferred short date format. 227 * Formats a time into the user's preferred short date format.
223 * 228 *
224 * The returned string is stored in a static buffer, so the result 229 * The returned string is stored in a static buffer, so the result
225 * should be g_strdup()'d if it's going to be kept. 230 * should be g_strdup()'d if it's going to be kept.
226 * 231 *
227 * @param time The time value to format (in local time). 232 * @param time The time to format, or @c NULL to use the current local time
228 * 233 *
229 * @return The date, formatted as per the user's settings. 234 * @return The date, formatted as per the user's settings.
230 */ 235 */
231 const char *gaim_date_format_short(const struct tm *tm); 236 const char *gaim_date_format_short(const struct tm *tm);
232 237
234 * Formats a time into the user's preferred short date plus time format. 239 * Formats a time into the user's preferred short date plus time format.
235 * 240 *
236 * The returned string is stored in a static buffer, so the result 241 * The returned string is stored in a static buffer, so the result
237 * should be g_strdup()'d if it's going to be kept. 242 * should be g_strdup()'d if it's going to be kept.
238 * 243 *
239 * @param time The time value to format (in local time). 244 * @param time The time to format, or @c NULL to use the current local time
240 * 245 *
241 * @return The timestamp, formatted as per the user's settings. 246 * @return The timestamp, formatted as per the user's settings.
242 */ 247 */
243 const char *gaim_date_format_long(const struct tm *tm); 248 const char *gaim_date_format_long(const struct tm *tm);
244 249
246 * Formats a time into the user's preferred full date and time format. 251 * Formats a time into the user's preferred full date and time format.
247 * 252 *
248 * The returned string is stored in a static buffer, so the result 253 * The returned string is stored in a static buffer, so the result
249 * should be g_strdup()'d if it's going to be kept. 254 * should be g_strdup()'d if it's going to be kept.
250 * 255 *
251 * @param time The time value to format (in local time). 256 * @param time The time to format, or @c NULL to use the current local time
252 * 257 *
253 * @return The date and time, formatted as per the user's settings. 258 * @return The date and time, formatted as per the user's settings.
254 */ 259 */
255 const char *gaim_date_format_full(time_t time); 260 const char *gaim_date_format_full(const struct tm *tm);
256 261
257 /** 262 /**
258 * Formats a time into the user's preferred time format. 263 * Formats a time into the user's preferred time format.
259 * 264 *
260 * The returned string is stored in a static buffer, so the result 265 * The returned string is stored in a static buffer, so the result
261 * should be g_strdup()'d if it's going to be kept. 266 * should be g_strdup()'d if it's going to be kept.
262 * 267 *
263 * @param time The time value to format (in local time). 268 * @param time The time value to format.
269 * @param time The time to format, or @c NULL to use the current local time
264 * 270 *
265 * @return The time, formatted as per the user's settings. 271 * @return The time, formatted as per the user's settings.
266 */ 272 */
267 const char *gaim_time_format(const struct tm *tm); 273 const char *gaim_time_format(const struct tm *tm);
268 274
279 * @return A time_t. 285 * @return A time_t.
280 */ 286 */
281 time_t gaim_time_build(int year, int month, int day, int hour, 287 time_t gaim_time_build(int year, int month, int day, int hour,
282 int min, int sec); 288 int min, int sec);
283 289
290 /** Used by gaim_str_to_time to indicate no timezone offset was
291 * specified in the timestamp string. */
292 #define GAIM_NO_TZ_OFF -500000
293
284 /** 294 /**
285 * Parses a timestamp in jabber, ISO8601, or MM/DD/YYYY format and returns 295 * Parses a timestamp in jabber, ISO8601, or MM/DD/YYYY format and returns
286 * a time_t. 296 * a time_t.
287 * 297 *
288 * @param timestamp The timestamp 298 * @param timestamp The timestamp
289 * @param utc Assume UTC if no timezone specified 299 * @param utc Assume UTC if no timezone specified
300 * @param tm If not @c NULL, the caller can get a copy of the
301 * struct tm used to calculate the time_t return value.
302 * @param tz_off If not @c NULL, the caller can get a copy of the
303 * timezone offset (from UTC) used to calculate the time_t
304 * return value. Note: Zero is a valid offset. As such,
305 * the value of the macro @c GAIM_NO_TZ_OFF indicates no
306 * offset was specified (which means that the local
307 * timezone was used in the calculation).
308 * @param rest If not @c NULL, the caller can get a pointer to the
309 * part of @a timestamp left over after parsing is
310 * completed, if it's not the end of @a timestamp.
290 * 311 *
291 * @return A time_t. 312 * @return A time_t.
292 */ 313 */
293 time_t gaim_str_to_time(const char *timestamp, gboolean utc); 314 time_t gaim_str_to_time(const char *timestamp, gboolean utc,
315 struct tm *tm, long *tz_off, const char **rest);
294 316
295 /*@}*/ 317 /*@}*/
296 318
297 319
298 /**************************************************************************/ 320 /**************************************************************************/