| 1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
| 2 | /* |
| 3 | * Copyright (C) 2005 Novell, Inc. |
| 4 | * Copyright (C) 2007 Red Hat, Inc. |
| 5 | */ |
| 6 | |
| 7 | #ifndef __SOUP_DATE_H__ |
| 8 | #define __SOUP_DATE_H__ 1 |
| 9 | |
| 10 | #include <time.h> |
| 11 | #include <libsoup/soup-types.h> |
| 12 | |
| 13 | G_BEGIN_DECLS |
| 14 | |
| 15 | struct _SoupDate { |
| 16 | int year; |
| 17 | int month; |
| 18 | int day; |
| 19 | |
| 20 | int hour; |
| 21 | int minute; |
| 22 | int second; |
| 23 | |
| 24 | gboolean utc; |
| 25 | int offset; |
| 26 | }; |
| 27 | |
| 28 | typedef enum { |
| 29 | SOUP_DATE_HTTP = 1, |
| 30 | SOUP_DATE_COOKIE, |
| 31 | SOUP_DATE_RFC2822, |
| 32 | SOUP_DATE_ISO8601_COMPACT, |
| 33 | SOUP_DATE_ISO8601_FULL, |
| 34 | SOUP_DATE_ISO8601 = SOUP_DATE_ISO8601_FULL, |
| 35 | SOUP_DATE_ISO8601_XMLRPC |
| 36 | } SoupDateFormat; |
| 37 | |
| 38 | SOUP_AVAILABLE_IN_2_24 |
| 39 | GType soup_date_get_type (void); |
| 40 | #define SOUP_TYPE_DATE (soup_date_get_type ()) |
| 41 | |
| 42 | SOUP_AVAILABLE_IN_2_24 |
| 43 | SoupDate *soup_date_new (int year, |
| 44 | int month, |
| 45 | int day, |
| 46 | int hour, |
| 47 | int minute, |
| 48 | int second); |
| 49 | SOUP_AVAILABLE_IN_2_24 |
| 50 | SoupDate *soup_date_new_from_string (const char *date_string); |
| 51 | SOUP_AVAILABLE_IN_2_24 |
| 52 | SoupDate *soup_date_new_from_time_t (time_t when); |
| 53 | SOUP_AVAILABLE_IN_2_24 |
| 54 | SoupDate *soup_date_new_from_now (int offset_seconds); |
| 55 | |
| 56 | SOUP_AVAILABLE_IN_2_24 |
| 57 | char *soup_date_to_string (SoupDate *date, |
| 58 | SoupDateFormat format); |
| 59 | SOUP_AVAILABLE_IN_2_24 |
| 60 | time_t soup_date_to_time_t (SoupDate *date); |
| 61 | SOUP_AVAILABLE_IN_2_24 |
| 62 | void soup_date_to_timeval (SoupDate *date, |
| 63 | GTimeVal *time); |
| 64 | |
| 65 | SOUP_AVAILABLE_IN_2_24 |
| 66 | gboolean soup_date_is_past (SoupDate *date); |
| 67 | |
| 68 | SOUP_AVAILABLE_IN_2_32 |
| 69 | int soup_date_get_year (SoupDate *date); |
| 70 | SOUP_AVAILABLE_IN_2_32 |
| 71 | int soup_date_get_month (SoupDate *date); |
| 72 | SOUP_AVAILABLE_IN_2_32 |
| 73 | int soup_date_get_day (SoupDate *date); |
| 74 | SOUP_AVAILABLE_IN_2_32 |
| 75 | int soup_date_get_hour (SoupDate *date); |
| 76 | SOUP_AVAILABLE_IN_2_32 |
| 77 | int soup_date_get_minute (SoupDate *date); |
| 78 | SOUP_AVAILABLE_IN_2_32 |
| 79 | int soup_date_get_second (SoupDate *date); |
| 80 | SOUP_AVAILABLE_IN_2_32 |
| 81 | int soup_date_get_utc (SoupDate *date); |
| 82 | SOUP_AVAILABLE_IN_2_32 |
| 83 | int soup_date_get_offset (SoupDate *date); |
| 84 | |
| 85 | SOUP_AVAILABLE_IN_2_24 |
| 86 | SoupDate *soup_date_copy (SoupDate *date); |
| 87 | SOUP_AVAILABLE_IN_2_24 |
| 88 | void soup_date_free (SoupDate *date); |
| 89 | |
| 90 | G_END_DECLS |
| 91 | |
| 92 | #endif /* __SOUP_DATE_H__ */ |
| 93 | |