summaryrefslogtreecommitdiff
path: root/libsoup/soup-date.h
blob: 7dbbc87dd511b6b24d685559d1123140fda6abbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2005 Novell, Inc.
 * Copyright (C) 2007 Red Hat, Inc.
 */

#ifndef __SOUP_DATE_H__
#define __SOUP_DATE_H__ 1

#include <time.h>
#include <libsoup/soup-types.h>

G_BEGIN_DECLS

struct _SoupDate {
	int      year;
	int      month;
	int      day;

	int      hour;
	int      minute;
	int      second;

	gboolean utc;
	int      offset;
};

typedef enum {
	SOUP_DATE_HTTP = 1,
	SOUP_DATE_COOKIE,
	SOUP_DATE_RFC2822,
	SOUP_DATE_ISO8601_COMPACT,
	SOUP_DATE_ISO8601_FULL,
	SOUP_DATE_ISO8601 = SOUP_DATE_ISO8601_FULL,
	SOUP_DATE_ISO8601_XMLRPC
} SoupDateFormat;

SOUP_AVAILABLE_IN_2_24
GType soup_date_get_type (void);
#define SOUP_TYPE_DATE (soup_date_get_type ())

SOUP_AVAILABLE_IN_2_24
SoupDate *soup_date_new             (int             year,
				     int             month,
				     int             day, 
				     int             hour,
				     int             minute,
				     int             second);
SOUP_AVAILABLE_IN_2_24
SoupDate *soup_date_new_from_string (const char     *date_string);
SOUP_AVAILABLE_IN_2_24
SoupDate *soup_date_new_from_time_t (time_t          when);
SOUP_AVAILABLE_IN_2_24
SoupDate *soup_date_new_from_now    (int             offset_seconds);

SOUP_AVAILABLE_IN_2_24
char     *soup_date_to_string       (SoupDate       *date,
				     SoupDateFormat  format);
SOUP_AVAILABLE_IN_2_24
time_t    soup_date_to_time_t       (SoupDate       *date);
SOUP_AVAILABLE_IN_2_24
void      soup_date_to_timeval      (SoupDate       *date,
				     GTimeVal       *time);

SOUP_AVAILABLE_IN_2_24
gboolean  soup_date_is_past         (SoupDate       *date);

SOUP_AVAILABLE_IN_2_32
int       soup_date_get_year        (SoupDate       *date);
SOUP_AVAILABLE_IN_2_32
int       soup_date_get_month       (SoupDate       *date);
SOUP_AVAILABLE_IN_2_32
int       soup_date_get_day         (SoupDate       *date);
SOUP_AVAILABLE_IN_2_32
int       soup_date_get_hour        (SoupDate       *date);
SOUP_AVAILABLE_IN_2_32
int       soup_date_get_minute      (SoupDate       *date);
SOUP_AVAILABLE_IN_2_32
int       soup_date_get_second      (SoupDate       *date);
SOUP_AVAILABLE_IN_2_32
int       soup_date_get_utc         (SoupDate       *date);
SOUP_AVAILABLE_IN_2_32
int       soup_date_get_offset      (SoupDate       *date);

SOUP_AVAILABLE_IN_2_24
SoupDate *soup_date_copy            (SoupDate       *date);
SOUP_AVAILABLE_IN_2_24
void      soup_date_free            (SoupDate       *date);

G_END_DECLS

#endif /* __SOUP_DATE_H__ */