### Example (localdtconv -- Return Date and Time Formatting Convention)

This example sets the Spanish locale, calls localdtconv to determine how date and time are formatted, and prints the fields from the resulting structure.

    #include <stdio.h>
    #include <stdlib.h>
    #include <locale.h>
    #include <stdlib.h>

    #if (1 == __TOS_OS2__)
       #define LOCNAME "es_es.ibm-437"      /* OS/2 name */
    #else
       #define LOCNAME "es_es.ibm-1252"  /* Windows name */
    #endif

    int main(void)
    {
       struct dtconv *p;
       int           i;

       if (NULL == setlocale(LC_ALL, LOCNAME)) {
          printf("Locale \"%s\" could not be loaded\n", LOCNAME);
          exit(1);
       } else {
          p = localdtconv();
          printf("SPAIN date/time convention.\n");
          printf(" Abbreviated month names:");
          for (i = 0; i < 12; ++i)
             printf(" %s", p->abbrev_month_names[i]);
          printf("\n Full month names:");
          for (i = 0; i < 12; ++i)
             printf(" %s", p->month_names[i]);
          printf("\n Abbreviated day names:");
          for (i = 0; i < 7; ++i)
             printf(" %s", p->abbrev_day_names[i]);
          printf("\n Full day names:");
          for (i = 0; i < 7; ++i)
             printf(" %s", p->day_names[i]);
          printf("\n Date and time format:  %s\n", p->date_time_format);
          printf(" Date format:  %s\n",            p->date_format);
          printf(" Time format:  %s\n",            p->time_format);
          printf(" AM string:  %s\n",              p->am_string);
          printf(" PM string:  %s\n",              p->pm_string);
          printf(" Long date format:  %s\n",       p->time_format_ampm);
       }
       return 0;

       /****************************************************************************
          The output should be similar to :

          SPAIN date/time convention.
           Abbreviated month names: Ene Feb Mar Abr May Jun Jul Ago Sep Oct Nov Dic
           Full month names: Enero Febrero Marzo Abril Mayo Junio Julio Agosto
                             Septiembre Octubre Noviembre Diciembre
           Abbreviated day names: Do Lu Ma Mi Ju Vi Sa
           Full day names: Domingo Lunes Martes Miercoles Jueves Viernes Sabado
           Date and time format:  %a %e %b %H:%M:%S %Y
           Date format:  %d/%m/%y
           Time format:  %H:%M:%S
           AM string:
           PM string:
           Long date format:  %I:%M:%S %p
       ****************************************************************************/
    }