### Example: Select a Locale Explicitly by Name

Here is a C program with an explicit reference to a locale called`` TEXAN. This program runs as described if you first create the TEXAN locale following the example for the steps to customize a locale.

    /* This example shows how to get the local time formatted
    by the current locale */

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

    int main(void){
    char dest[80];
    int ch;
    time_t temp;
    struct tm *timeptr;
    char *locname;
    temp = time(NULL);
    timeptr = localtime(&temp);

    /* Fetch default locale name */
    printf("Default locale is %s\n", (locname = setlocale(LC_ALL,"") ));
    ch = strftime(dest, sizeof(dest)-1, "datetime is %c", timeptr);
    printf("Locale %s %s\n", locname, dest);

    /* Set new Texan locale name */
    printf("New locale is %s\n", (locname = setlocale(LC_ALL,"Texan")));
    ch = strftime(dest, sizeof(dest)-1, "datetime is %c", timeptr);
    printf("Locale %s %s\n", locname, dest);

    return(0);
    }

When you build and run this program, you should see output similar to:

    Default locale is C
    Locale C datetime is Fri Aug 20 14:58:12  1993
    New locale is Texan
    Locale Texan datetime is Howdy Pardner Fri Aug 20 14:58:12  1993

Example: Customize an Existing Locale

Internationalization
Localization and Locales

Make Your Program International
Select a Locale
Customize a Locale

Locale-Sensitive Interfaces