Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

NLSGetLocaleInfo

NLS Function: Returns information about the current locale. This routine is only available for Windows.

Module

USE IFNLS

result = NLSGetLocaleInfo (type,outstr)

type

(Input) INTEGER(4). Is the NLS parameter requested. A list of parameter names is provided in NLS LocaleInfo Parameters.

outstr

(Output) Character*(*). Is the parameter setting for the current locale. All parameter settings placed in outstr are character strings, even numbers. If a parameter setting is numeric, the ASCII representation of the number is used.

If the requested parameter is a date or time string, an explanation of how to interpret the format in outstr is provided in NLS Date and Time Format.

Results

The result type is INTEGER(4). The result is the number of characters written to outstr if successful, or if outstr has 0 length, the number of characters required to hold the requested information.

Otherwise, the result is one of the following error codes (defined in IFNLS.F90):

  • NLS$ErrorInvalidInput - type has an illegal value.

  • NLS$ErrorInsufficientBuffer - The outstr buffer was too small, but was not 0 (so that the needed size would be returned).

The NLS$LI parameters are used for the argument type and select the locale information returned by NLSGetLocaleInfo in outstr. You can perform an inclusive OR with NLS$NoUserOverride and any NLS$LI parameter. This causes NLSGetLocaleInfo to bypass any user overrides and always return the system default value.

The following table lists and describes the NLS$LI parameters in alphabetical order.

NLS LocaleInfo Parameters

Parameter

Description

NLS$LI_ICALENDARTYPE

Specifies which type of calendar is currently being used:

1 - Gregorian (as in United States)

2 - Gregorian (English strings always)

3 - Era: Year of the Emperor (Japan)

4 - Era: Year of the Republic of China

5 - Tangun Era (Korea)

NLS$LI_ICENTURY

Specifies whether to use full 4-digit century for the short date only:

0 - Two-digit year

1 - Full century

NLS$LI_ICOUNTRY

Is the country code, based on international phone codes, also referred to as IBM country codes.

NLS$LI_ICURRDIGITS

Is the number of decimal digits for the local monetary format.

NLS$LI_ICURRENCY

Determines how positive currency is represented:

0 - Puts currency symbol in front with no separation: $1.1

1 - Puts currency symbol in back with no separation: 1.1$

2 - Puts currency symbol in front with single space after: $ 1.1

3 - Puts currency symbol in back with single space before: 1.1 $

When NLSGetLocaleInfo ( type, outstr) returns information about the date and time formats of the current locale, the value returned in outstr can be interpreted according to the following tables.

Any text returned within a date and time string that is enclosed within single quotes should be left in the string in its exact form; that is, do not change the text or the location within the string.

Day

The day can be displayed in one of four formats using the letter "d". The following table shows the four variations:

d

Day of the month as digits without leading zeros for single-digit days

dd

Day of the month as digits with leading zeros for single-digit days

ddd

Day of the week as a three-letter abbreviation (SABBREVDAYNAME)

dddd

Day of the week as its full name (SDAYNAME)

Month

The month can be displayed in one of four formats using the letter "M". The uppercase "M" distinguishes months from minutes. The following table shows the four variations:

M

Month as digits without leading zeros for single-digit months

MM

Month as digits with leading zeros for single-digit months

MMM

Month as a three-letter abbreviation (SABBREVMONTHNAME)

MMMM

Month as its full name (SMONTHNAME)

Year

The year can be displayed in one of three formats using the letter "y". The following table shows the three variations:

y

Year represented by only the last digit

yy

Year represented by only the last two digits

yyyy

Year represented by the full 4 digits

Period/Era

The period/era string is displayed in a single format using the letters "gg".

gg

Period/Era string

Time

The time can be displayed in one of many formats using the letter "h" or "H" to denote hours, the letter "m" to denote minutes, the letter "s" to denote seconds and the letter "t" to denote the time marker.

The following table shows the numerous variations of the time format. Lowercase "h" denotes the 12 hour clock and uppercase "H" denotes the 24 hour clock. The lowercase "m" distinguishes minutes from months.

h

Hours without leading zeros for single-digit hours (12 hour clock)

hh

Hours with leading zeros for single-digit hours (12 hour clock)

H

Hours without leading zeros for single-digit hours (24 hour clock)

HH

Hours with leading zeros for single-digit hours (24 hour clock)

m

Minutes without leading zeros for single-digit minutes

Example

 USE IFNLS
 INTEGER(4) strlen
 CHARACTER(40) str
 strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME1, str)
 print *, str    ! prints Monday if language is English
 strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME2, str)
 print *, str    ! prints Tuesday if language is English