diff options
Diffstat (limited to 'lib/isc/unix/time.c')
| -rw-r--r-- | lib/isc/unix/time.c | 22 | 
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/isc/unix/time.c b/lib/isc/unix/time.c index e820afb1eaa07..890b9192ba5ad 100644 --- a/lib/isc/unix/time.c +++ b/lib/isc/unix/time.c @@ -1,5 +1,5 @@  /* - * Copyright (C) 2004-2008, 2011, 2012  Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008, 2011, 2012, 2014  Internet Systems Consortium, Inc. ("ISC")   * Copyright (C) 1998-2001, 2003  Internet Software Consortium.   *   * Permission to use, copy, modify, and/or distribute this software for any @@ -23,6 +23,7 @@  #include <errno.h>  #include <limits.h> +#include <stdlib.h>  #include <syslog.h>  #include <time.h> @@ -33,6 +34,7 @@  #include <isc/strerror.h>  #include <isc/string.h>  #include <isc/time.h> +#include <isc/tm.h>  #include <isc/util.h>  #define NS_PER_S	1000000000	/*%< Nanoseconds per second. */ @@ -407,6 +409,24 @@ isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len) {  	INSIST(flen < len);  } +isc_result_t +isc_time_parsehttptimestamp(char *buf, isc_time_t *t) { +	struct tm t_tm; +	time_t when; +	char *p; + +	REQUIRE(buf != NULL); +	REQUIRE(t != NULL); +	p = isc_tm_strptime(buf, "%a, %d %b %Y %H:%M:%S", &t_tm); +	if (p == NULL) +		return (ISC_R_UNEXPECTED); +	when = isc_tm_timegm(&t_tm); +	if (when == -1) +		return (ISC_R_UNEXPECTED); +	isc_time_set(t, when, 0); +	return (ISC_R_SUCCESS); +} +  void  isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len) {  	time_t now;  | 
