From 33da2fabe6c3b1e20a955d72e1ebd0e850751df0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 06:30:47 +0000 Subject: r10914: moved the ldap time string functions into ldb so they can be used by the time attribute handling functions (This used to be commit 93c296d52718e77f8b702e1721b548eaadc56c76) --- source4/lib/time.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'source4/lib/time.c') diff --git a/source4/lib/time.c b/source4/lib/time.c index 5de9046c8d..c9cf0b9630 100644 --- a/source4/lib/time.c +++ b/source4/lib/time.c @@ -301,47 +301,6 @@ char *http_timestring(TALLOC_CTX *mem_ctx, time_t t) return buf; } -/* - return a LDAP time string -*/ -char *ldap_timestring(TALLOC_CTX *mem_ctx, time_t t) -{ - struct tm *tm = gmtime(&t); - - if (!tm) { - return NULL; - } - - /* formatted like: 20040408072012.0Z */ - return talloc_asprintf(mem_ctx, - "%04u%02u%02u%02u%02u%02u.0Z", - tm->tm_year+1900, tm->tm_mon+1, - tm->tm_mday, tm->tm_hour, tm->tm_min, - tm->tm_sec); -} - - -/* - convert a LDAP time string to a time_t. Return 0 if unable to convert -*/ -time_t ldap_string_to_time(const char *s) -{ - struct tm tm; - - if (s == NULL) return 0; - - ZERO_STRUCT(tm); - if (sscanf(s, "%04u%02u%02u%02u%02u%02u.0Z", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday, - &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { - return 0; - } - tm.tm_year -= 1900; - tm.tm_mon -= 1; - - return timegm(&tm); -} - /**************************************************************************** Return the date and time as a string ****************************************************************************/ -- cgit