NLS Formatting Routines

You can set time, date, currency and number formats from the Control Panel, by clicking on the Regional Settings icon. The NLS Library also provides formatting routines for the current locale. These routines are summarized in the following table. These routines return strings in the current codepage, set by default at program start or by NLSSetLocale.

All the formatting routines return the number of bytes in the formatted string (not the number of characters, which can vary if multibyte characters are included). If the output string is longer than the formatted string, the output string is blank padded. If the output string is shorter than the formatted string, an error occurs, NLS$ErrorInsufficientBuffer is returned, and nothing is written to the output string.

Formatting Routines

Name Procedure Type Description
NLSFormatCurrency Function Formats a number string and returns the correct currency string for the current locale
NLSFormatDate Function Returns a correctly formatted string containing the date for the current locale
NLSFormatNumber Function Formats a number string and returns the correct number string for the current locale
NLSFormatTime Function Returns a correctly formatted string containing the time for the current locale

As an example:

     USE DFNLS
     INTEGER(4) strlen, status
     CHARACTER(40) str
     strlen = NLSFormatTime(str)
     print *, str             ! prints               11:42:24 AM
     strlen = NLSFormatDate(str, flags= NLS$LongDate)
     print *, str             ! prints        Friday, July 14, 2000
     status = NLSSetLocale ("Spanish", "Mexico")
     strlen = NLSFormatTime(str)
     print *, str             ! prints               11:42:24
     print *, str             ! prints viernes 14 de julio de 2000