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
13G_BEGIN_DECLS
14
15struct _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
28typedef 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
38SOUP_AVAILABLE_IN_2_24
39GType soup_date_get_type (void);
40#define SOUP_TYPE_DATE (soup_date_get_type ())
41
42SOUP_AVAILABLE_IN_2_24
43SoupDate *soup_date_new (int year,
44 int month,
45 int day,
46 int hour,
47 int minute,
48 int second);
49SOUP_AVAILABLE_IN_2_24
50SoupDate *soup_date_new_from_string (const char *date_string);
51SOUP_AVAILABLE_IN_2_24
52SoupDate *soup_date_new_from_time_t (time_t when);
53SOUP_AVAILABLE_IN_2_24
54SoupDate *soup_date_new_from_now (int offset_seconds);
55
56SOUP_AVAILABLE_IN_2_24
57char *soup_date_to_string (SoupDate *date,
58 SoupDateFormat format);
59SOUP_AVAILABLE_IN_2_24
60time_t soup_date_to_time_t (SoupDate *date);
61SOUP_AVAILABLE_IN_2_24
62void soup_date_to_timeval (SoupDate *date,
63 GTimeVal *time);
64
65SOUP_AVAILABLE_IN_2_24
66gboolean soup_date_is_past (SoupDate *date);
67
68SOUP_AVAILABLE_IN_2_32
69int soup_date_get_year (SoupDate *date);
70SOUP_AVAILABLE_IN_2_32
71int soup_date_get_month (SoupDate *date);
72SOUP_AVAILABLE_IN_2_32
73int soup_date_get_day (SoupDate *date);
74SOUP_AVAILABLE_IN_2_32
75int soup_date_get_hour (SoupDate *date);
76SOUP_AVAILABLE_IN_2_32
77int soup_date_get_minute (SoupDate *date);
78SOUP_AVAILABLE_IN_2_32
79int soup_date_get_second (SoupDate *date);
80SOUP_AVAILABLE_IN_2_32
81int soup_date_get_utc (SoupDate *date);
82SOUP_AVAILABLE_IN_2_32
83int soup_date_get_offset (SoupDate *date);
84
85SOUP_AVAILABLE_IN_2_24
86SoupDate *soup_date_copy (SoupDate *date);
87SOUP_AVAILABLE_IN_2_24
88void soup_date_free (SoupDate *date);
89
90G_END_DECLS
91
92#endif /* __SOUP_DATE_H__ */
93