1 /**
2  * @file common.c common routines for Liferea
3  *
4  * Copyright (C) 2003-2005  Lars Lindner <lars.lindner@gmx.net>
5  * Copyright (C) 2004,2005  Nathan J. Conrad <t98502@users.sourceforge.net>
6  * Copyright (C) 2004       Karl Soderstrom <ks@xanadunet.net>
7  *
8  * parts of the RFC822 timezone decoding were taken from the gmime
9  * source written by
10  *
11  * Authors: Michael Zucchi <notzed@helixcode.com>
12  *          Jeffrey Stedfast <fejj@helixcode.com>
13  *
14  * Copyright 2000 Helix Code, Inc. (www.helixcode.com)
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 2 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29  */
30 
31 #ifdef HAVE_CONFIG_H
32 #  include <config.h>
33 #endif
34 
35 /* this is needed for strptime() */
36 #define _XOPEN_SOURCE /* glibc2 needs this */
37 
38 #include <time.h>
39 #include <glib.h>
40 //#include <locale.h>
41 //#include <string.h>
42 //#include <ctype.h>
43 //#include <stdlib.h>
44 
45 gchar *dayofweek[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
46 gchar *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
47 
createRFC822Date(const time_t * time)48 gchar *createRFC822Date(const time_t *time) {
49 	struct tm *tm;
50 
51 	tm = gmtime(time); /* No need to free because it is statically allocated */
52 	return g_strdup_printf("%s, %2d %s %4d %02d:%02d:%02d GMT", dayofweek[tm->tm_wday], tm->tm_mday,
53 					   months[tm->tm_mon], 1900 + tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec);
54 }
55