Logo Search packages:      
Sourcecode: ldb version File versions  Download package

time_t ldb_string_to_time ( const char *  s  ) 

Convert a string to a time structure

This function converts an LDAP formatted GeneralizedTime string to a time_t structure.

Parameters:
s the string to convert
Returns:
the time structure, or 0 if the string cannot be converted

Definition at line 788 of file ldb_msg.c.

{
      struct tm tm;
      
      if (s == NULL) return 0;
      
      memset(&tm, 0, sizeof(tm));
      if (sscanf(s, "%04u%02u%02u%02u%02u%02u", 
               &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);
}


Generated by  Doxygen 1.6.0   Back to index