This example shows how to convert a time date string to a time structure.

#include <stdio.h>
#include <time.h>
#include <unidef.h>

int main(void) {

LocaleObject  locale_object;

UniChar       uni_fmt[] = L"%A %b %d %r %Y";
UniChar       uni_time_str[] = L"Wednesday Oct 23 03:07:00 PM 1995";
UniChar       *puni;
struct tm     convrt_time;
int           rc;


         rc = UniCreateLocaleObject(UNI_UCS_STRING_POINTER,
                                   (UniChar *)L"en_US", &locale_object);

         if (rc != ULS_SUCCESS) {
           printf("UniCreateLocaleObject error: return code = %u\n", rc);
           return 1;
         }

         puni = UniStrptime(locale_object, uni_time_str, uni_fmt,
                           &convrt_time);

         if ( puni == NULL ) {
             printf("UniStrptime error\n");
             return (1);
         }

         else
             return (ULS_SUCCESS);


}


[Back: UniStrptime - Related Functions]
[Next: UniStrptime - Topics]