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 62 #ifndef SOUP_DISABLE_DEPRECATED 63 G_GNUC_BEGIN_IGNORE_DEPRECATIONS 64 SOUP_AVAILABLE_IN_2_24 65 SOUP_DEPRECATED_IN_2_70 66 void soup_date_to_timeval (SoupDate *date, 67 GTimeVal *time); 68 G_GNUC_END_IGNORE_DEPRECATIONS 69 #endif 70 71 SOUP_AVAILABLE_IN_2_24 72 gboolean soup_date_is_past (SoupDate *date); 73 74 SOUP_AVAILABLE_IN_2_32 75 int soup_date_get_year (SoupDate *date); 76 SOUP_AVAILABLE_IN_2_32 77 int soup_date_get_month (SoupDate *date); 78 SOUP_AVAILABLE_IN_2_32 79 int soup_date_get_day (SoupDate *date); 80 SOUP_AVAILABLE_IN_2_32 81 int soup_date_get_hour (SoupDate *date); 82 SOUP_AVAILABLE_IN_2_32 83 int soup_date_get_minute (SoupDate *date); 84 SOUP_AVAILABLE_IN_2_32 85 int soup_date_get_second (SoupDate *date); 86 SOUP_AVAILABLE_IN_2_32 87 int soup_date_get_utc (SoupDate *date); 88 SOUP_AVAILABLE_IN_2_32 89 int soup_date_get_offset (SoupDate *date); 90 91 SOUP_AVAILABLE_IN_2_24 92 SoupDate *soup_date_copy (SoupDate *date); 93 SOUP_AVAILABLE_IN_2_24 94 void soup_date_free (SoupDate *date); 95 96 G_END_DECLS 97 98 #endif /* __SOUP_DATE_H__ */ 99