All pastes #728230 Raw Edit

Miscellany

public c v1 · immutable
·published 2007-10-06 20:08 UTC
rendered paste body
#include <stdio.h>#define _XOPEN_SOURCE#include <time.h>time_t strtotime (const char *s_time);int main (){	struct tm	*ts_gmt;	time_t		 time_post;	time_t		 time_gmt;	time_t		 time_local = time(NULL);	/* Get post timestamp */	time_post = strtotime ("Sat Oct 06 19:52:04 +0000 2007");	/* Get GMT time */	ts_gmt = gmtime ( &time_local );	time_gmt = mktime (ts_gmt);	printf ("POST: %d\n GMT: %d\n Diff: %d\n",		time_post,		time_gmt,		time_gmt-time_post);	return 0;}time_tstrtotime (const char *s_time){	struct tm time;	strptime (s_time, "%a %b %d %T +0000 %Y", &time);	return mktime(&time);}