r576: added a ldap_timestring() function (needed for fields like whenChanged in SAM db)
authorAndrew Tridgell <tridge@samba.org>
Fri, 7 May 2004 23:56:57 +0000 (23:56 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:51:48 +0000 (12:51 -0500)
source/lib/time.c

index 0aef931fe0e06497a3355312b478f0c4026de600..0bc5fcd3fc24feee8401d65ebb45cce75a514123 100644 (file)
@@ -339,6 +339,25 @@ 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);
+}
+
 
 
 /****************************************************************************