The ESQL/C DATE-format functions are as follows:
These functions support extensions to format era-based DATE values:
This section describes locale-specific behavior of the ESQL/C DATE-format functions. For details, see the IBM Informix: ESQL/C Programmer's Manual.
The GL_DATE setting les can affect the results that these ESQL/C DATE-format functions generate. The end-user format that GL_DATE specifies overrides date end-user formats that the client locale defines. For more information, see Precedence for Date End-User Formats.
The ESQL/C DATE-format functions that support the extended era-based date syntax for the DBDATE environment variable are as follows:
When you set DBDATE to one of the era-based formats, these functions use era-based dates to convert between date strings and internal DATE values. The following ESQL/C example shows a call to the rdatestr() library function:
char str[100]; long jdate; ... rdatestr(jdate, str); printf("%s\n", str);
If you set DBDATE to GY2MD/ and CLIENT_LOCALE to the Japanese SJIS locale (ja_jp.sjis), the preceding code prints this value for the date 08/18/1990:
H02/08/18
If you set DBDATE to a era-based date format (which is specific to a Chinese or Japanese locale), make sure to set the CLIENT_LOCALE environment variable to a locale that supports era-based dates.
The ESQL/C DATE-format functions that support the extended-DATE format strings are as follows:
The following table shows the extended-format strings that these ESQL/C functions support for use with GLS locales. These extended-format strings format eras with 2-digit year offsets.
Era Year | Format | Era Used |
---|---|---|
Full era year: full name of the base year (period) followed by a 2-digit year offset. Same as GL_DATE end-user format of "%EC%02.2Ey" | eyy | The era that the client locale (which CLIENT_LOCALE indicates) defines |
Abbreviated era year: abbreviated name of the base year (period) followed by a 2-digit year offset. Same as GL_DATE end-user format of "%Eg%02.2Ey" | gyy | The era that the client locale (which CLIENT_LOCALE indicates) defines |
The following table shows some extended-format strings for era-based dates. These examples assume that the client locale is Japanese SJIS (ja_jp.sjis).
Description | Example Format | October 5, 1990 prints as: |
---|---|---|
Abbreviated era year | gyymmdd
gyy.mm.dd |
H021005
H02.10.05 |
Full era year | eyymmdd
eyy-mm-dd eyyB1B2mmB1B2ddB1B2 |
A1A2021005
A1A202-10-05 A1A202B1B210B1B205B1B2 |
The following ESQL/C code fragment contains a call to the rdefmtdate() library function:
char fmt_str[100]; char in_str[100]; long jdate; ... rdatestr("10/05/95", &jdate); stcopy("gyy/mm/dd", fmt_str); rdefmtdate(&jdate, fmt_str, in_str); printf("Abbreviated Era Year: %s\n", in_str); stcopy("eyymmdd", fmt_str); rdefmtdate(&jdate, fmt_str, in_str); printf("Full Era Year: %s\n", in_str);
When the CLIENT_LOCALE specifies the Japanese SJIS (ja_jp.sjis) locale, the code fragment displays the following output:
Abbreviated Era Year: H07/10/05 Full Era Year: H021005
The ESQL/C DATE-format functions use the following precedence to determine the end-user format for values in DATE columns:
For more information on the precedence of DBDATE, GL_DATE, and CLIENT_LOCALE, refer to Date and Time Precedence.