Mercurial > pidgin
comparison src/util.h @ 13104:e1e5462b7d81
[gaim-migrate @ 15466]
Rework lots of date parsing. I either introduced a whole lot of bugs, or I've made sure all dates are localized properly now. Only time will tell which it is... ;)
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 02 Feb 2006 19:50:51 +0000 |
parents | 5828d42e8684 |
children | fcde3faa1f57 |
comparison
equal
deleted
inserted
replaced
13103:a6811e213977 | 13104:e1e5462b7d81 |
---|---|
43 GaimCallback callback; | 43 GaimCallback callback; |
44 gpointer data; | 44 gpointer data; |
45 GList *children; | 45 GList *children; |
46 } GaimMenuAction; | 46 } GaimMenuAction; |
47 | 47 |
48 typedef char *(*GaimInfoFieldFormatCallback)(const char *field, size_t len); | |
49 | |
48 /** | 50 /** |
49 * A key-value pair. | 51 * A key-value pair. |
50 * | 52 * |
51 * This is used by, among other things, gaim_gtk_combo* functions to pass in a | 53 * This is used by, among other things, gaim_gtk_combo* functions to pass in a |
52 * list of key-value pairs so it can display a user-friendly value. | 54 * list of key-value pairs so it can display a user-friendly value. |
207 /** @name Date/Time Functions */ | 209 /** @name Date/Time Functions */ |
208 /**************************************************************************/ | 210 /**************************************************************************/ |
209 /*@{*/ | 211 /*@{*/ |
210 | 212 |
211 /** | 213 /** |
214 * Formats a time into the specified format. | |
215 * | |
216 * This is essentially strftime(), but it has a static buffer | |
217 * and handles the UTF-8 conversion for the caller. | |
218 */ | |
219 const char *gaim_utf8_strftime(const char *format, const struct tm *tm); | |
220 | |
221 /** | |
222 * Formats a time into the user's preferred short date format. | |
223 * | |
224 * 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. | |
226 * | |
227 * @param time The time value to format (in local time). | |
228 * | |
229 * @return The date, formatted as per the user's settings. | |
230 */ | |
231 const char *gaim_date_format_short(const struct tm *tm); | |
232 | |
233 /** | |
234 * Formats a time into the user's preferred short date plus time format. | |
235 * | |
236 * 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. | |
238 * | |
239 * @param time The time value to format (in local time). | |
240 * | |
241 * @return The timestamp, formatted as per the user's settings. | |
242 */ | |
243 const char *gaim_date_format_long(const struct tm *tm); | |
244 | |
245 /** | |
246 * Formats a time into the user's preferred full date and time format. | |
247 * | |
248 * 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. | |
250 * | |
251 * @param time The time value to format (in local time). | |
252 * | |
253 * @return The date and time, formatted as per the user's settings. | |
254 */ | |
255 const char *gaim_date_format_full(time_t time); | |
256 | |
257 /** | |
258 * Formats a time into the user's preferred time format. | |
259 * | |
260 * 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. | |
262 * | |
263 * @param time The time value to format (in local time). | |
264 * | |
265 * @return The time, formatted as per the user's settings. | |
266 */ | |
267 const char *gaim_time_format(const struct tm *tm); | |
268 | |
269 /** | |
212 * Builds a time_t from the supplied information. | 270 * Builds a time_t from the supplied information. |
213 * | 271 * |
214 * @param year The year. | 272 * @param year The year. |
215 * @param month The month. | 273 * @param month The month. |
216 * @param day The day. | 274 * @param day The day. |
222 */ | 280 */ |
223 time_t gaim_time_build(int year, int month, int day, int hour, | 281 time_t gaim_time_build(int year, int month, int day, int hour, |
224 int min, int sec); | 282 int min, int sec); |
225 | 283 |
226 /** | 284 /** |
227 * Parses a timestamp in jabber or ISO8601 format and returns a time_t. | 285 * Parses a timestamp in jabber, ISO8601, or MM/DD/YYYY format and returns |
286 * a time_t. | |
228 * | 287 * |
229 * @param timestamp The timestamp | 288 * @param timestamp The timestamp |
230 * @param utc Assume UTC if no timezone specified | 289 * @param utc Assume UTC if no timezone specified |
231 * | 290 * |
232 * @return A time_t. | 291 * @return A time_t. |
233 */ | 292 */ |
234 time_t gaim_str_to_time(const char *timestamp, gboolean utc); | 293 time_t gaim_str_to_time(const char *timestamp, gboolean utc); |
235 | |
236 /** | |
237 * Creates a string according to a time and format string | |
238 * | |
239 * This function just calls strftime. The only advantage to using it | |
240 * is that gcc won't give a warning if you use %c | |
241 * | |
242 * TODO: The warning is gone in gcc4, and this function can | |
243 * eventually be removed. | |
244 */ | |
245 size_t gaim_strftime(char *s, size_t max, const char *format, const struct tm *tm); | |
246 | 294 |
247 /*@}*/ | 295 /*@}*/ |
248 | 296 |
249 | 297 |
250 /**************************************************************************/ | 298 /**************************************************************************/ |
287 * @param check_value The value that the last character must meet. | 335 * @param check_value The value that the last character must meet. |
288 * @param no_value_token The token indicating no value is given. | 336 * @param no_value_token The token indicating no value is given. |
289 * @param display_name The short descriptive name to display for this token. | 337 * @param display_name The short descriptive name to display for this token. |
290 * @param is_link TRUE if this should be a link, or FALSE otherwise. | 338 * @param is_link TRUE if this should be a link, or FALSE otherwise. |
291 * @param link_prefix The prefix for the link. | 339 * @param link_prefix The prefix for the link. |
340 * @param format_cb A callback to format the value before adding it. | |
292 * | 341 * |
293 * @return TRUE if successful, or FALSE otherwise. | 342 * @return TRUE if successful, or FALSE otherwise. |
294 */ | 343 */ |
295 gboolean gaim_markup_extract_info_field(const char *str, int len, GString *dest, | 344 gboolean gaim_markup_extract_info_field(const char *str, int len, GString *dest, |
296 const char *start_token, int skip, | 345 const char *start_token, int skip, |
297 const char *end_token, char check_value, | 346 const char *end_token, char check_value, |
298 const char *no_value_token, | 347 const char *no_value_token, |
299 const char *display_name, gboolean is_link, | 348 const char *display_name, gboolean is_link, |
300 const char *link_prefix); | 349 const char *link_prefix, |
350 GaimInfoFieldFormatCallback format_cb); | |
301 | 351 |
302 /** | 352 /** |
303 * Converts HTML markup to XHTML. | 353 * Converts HTML markup to XHTML. |
304 * | 354 * |
305 * @param html The HTML markup. | 355 * @param html The HTML markup. |