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

time_t ldb_string_utc_to_time ( const char *  s  ) 

Convert a string to a time structure

This function converts an LDAP formatted UTCTime 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 840 of file ldb_msg.c.

{
      struct tm tm;
      
      if (s == NULL) return 0;
      
      memset(&tm, 0, sizeof(tm));
      if (sscanf(s, "%02u%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;
      }
      if (tm.tm_year < 50) {
            tm.tm_year += 100;
      }
      tm.tm_mon -= 1;
      
      return timegm(&tm);
}


Generated by  Doxygen 1.6.0   Back to index