3.4 CS_LOCALE Objects

CS_LOCALE objects are a wrapper around the Sybase CS_LOCALE structure. The objects are created by calling the cs_loc_alloc() method of a CS_CONTEXT object.

They have the following interface:

cs_dt_info( action, type [, ...])
Sets or retrieves datetime information of the locale object

When action is CS_SET a compatible value argument must be supplied and the method returns the Sybase result code. The Sybase-CT cs_dt_info() function is called like this:

status = cs_dt_info(ctx, CS_SET, locale, type, CS_UNUSED,
                    &int_value, sizeof(int_value), &out_len);

When action is CS_GET the method returns a tuple containing the Sybase result code and a value. When a string value is requested an optional item argument can be passed which defaults to CS_UNUSED.

The return result depends upon the value of the type argument.

type need item? return values
CS_12HOUR no status, bool
CS_DT_CONVFMT no status, int
CS_MONTH yes status, string
CS_SHORTMONTH yes status, string
CS_DAYNAME yes status, string
CS_DATEORDER no status, string

The Sybase-CT cs_dt_info() function is called like this:

/* bool value */
status = cs_dt_info(ctx, CS_GET, locale, type, CS_UNUSED,
                    &bool_value, sizeof(bool_value), &out_len);

/* int value */
status = cs_dt_info(ctx, CS_GET, locale, type, CS_UNUSED,
                    &int_value, sizeof(int_value), &out_len);

/* string value */
status = cs_dt_info(ctx, CS_GET, locale, type, item,
                    str_buff, sizeof(str_buff), &buff_len);

cs_loc_drop( )
Calls the Sybase cs_loc_drop() function like this:

status = cs_loc_drop(ctx, locale);

Returns the Sybase result code.

This method will be automatically called when the CS_LOCALE object is deleted. Applications do not need to call the method.

cs_locale( action, type [, value])
Load the object with localisation values or retrieves the locale name previously used to load the object.

When action is CS_SET a string value argument must be supplied and the method returns the Sybase result code. The Sybase-CT cs_locale() function is called like this:

status = cs_locale(ctx, CS_SET, locale, type, value, CS_NULLTERM, NULL);

The recognised values for type are:

type
CS_LC_COLLATE
CS_LC_CTYPE
CS_LC_MESSAGE
CS_LC_MONETARY
CS_LC_NUMERIC
CS_LC_TIME
CS_LC_ALL
CS_SYB_LANG
CS_SYB_CHARSET
CS_SYB_SORTORDER
CS_SYB_COLLATE
CS_SYB_LANG_CHARSET
CS_SYB_TIME
CS_SYB_MONETARY
CS_SYB_NUMERIC

When action is CS_GET the method returns a tuple containing the Sybase result code and a locale name. The Sybase-CT cs_locale() function is called like this:

status = cs_locale(ctx, CS_GET, locale, type, str_buff, sizeof(str_buff), &str_len);