Informix and the Minguo “Y1C Problem”
The “Y1C Problem” affects
Minguo dates, a calendar currently used in the Republic of China (Taiwan). The issues are similar to those encountered
in the Y2K Problem.
The Minguo calendar begins with year 1 in 1912, the year the Republic of China was founded. Months and days in the Minguo calendar are the same as the Gregorian calendar. 2010 is year 99 of the Minguo calendar, and year 2011 will be year 100 - the year the Y1C problem is encountered.
The first Minguo century is from Minguo year 1 (1912) through 100 (2011) and the second Minguo century is from Minguo year 101 through 200. The century part of the Minguo year refers to the digit in the hundreds numeric position, not the century the year belongs in (just as the year 2010 is in the 21st century but the century part of the year 2010 is 20).
The Y1C problem in IDS has two issues:
- Supporting 3 digit years in Minguo dates
- Providing a means of determining the century for Minguo dates with 2 digit years
3 digit year support:
Prior to a change made in October 2008, only 2 or 4 digit year formats were supported for Minguo years, e.g. DMY2/C1 and DMY4/C1. The change added support for the DMY3/C1 format specifier. The fix was implemented in versions 11.10xC3, 10.00xC10 and 11.50xC1.
Minguo support of the DBCENTURY environment variable
The second fix adds DBCENTURY support for Minguo years. Previous to the fix (11.50xC7), DBCENTURY settings were ignored when formatting Minguo dates. If you specified a 2 digit year in a Minguo date and formatted it to a 3 digit year, it would always have returned a year with the century digit set to 0. With the fix, the century part of a 2 digit year formatted to 3 or 4 digit year will depend on the DBCENTURY setting.
DBCENTURY settings and their meanings:
R – Current century - century from the current date
P – Past century - century for the date earlier than current date
F – Future century - century for the date later than current date
C – Closest century - century for date closest to current date
Some examples:
The following table demonstrates the results of formatting Minguo dates with 2 digit years into Minguo dates with 3 digit years with various DBCENTURY settings and current dates. The “Current Date” column is the date the action occurs on.
Environment variables (other than DBCENTURY):
DB_LOCALE=zh_TW.big5
CLIENT_LOCALE= zh_TW.big5
DBDATE=MDY3/C1
DBCENTURY |
Current Date (Gregorian) |
Current Date (Minguo) |
Minguo input date with 2 digit year |
Resulting Minguo century |
Minguo input date with Y3 formatted year |
R |
01/01/2010 |
01/01/099 |
08/08/08 |
0 |
08/08/008 |
R |
01/01/2011 |
01/01/100 |
08/08/08 |
1 |
08/08/108 |
P |
08/08/2011 |
08/08/100 |
08/08/08 |
0 |
08/08/008 |
P |
08/08/2021 |
08/08/110 |
08/08/08 |
1 |
08/08/108 |
F |
08/08/2011 |
08/08/100 |
08/08/08 |
1 |
08/08/108 |
F |
08/08/2021 |
08/08/110 |
08/08/08 |
2 |
08/08/208 |
C |
08/08/2011 |
08/08/100 |
08/07/00 |
1 |
08/07/100 |
C |
08/08/2011 |
08/08/100 |
08/09/00 |
1 |
08/07/100 |
C |
08/08/2011 |
08/08/100 |
08/07/50 |
1 |
08/07/150 |
C |
08/08/2011 |
08/08/100 |
08/09/50 |
0 |
08/09/050 |
Without the fix, the 3 digit formatted dates would all have had a 0 in the century (100’s) place. Note that if a -1 century would be returned, we will return a 0 instead since there is no -1 century in the Minguo calendar.
Minguo DBCENTURY support is included in 11.50xC7.
Example of use:
Create the following two files, then run test.sh.
Test.sh:
#!/bin/sh
if [ "x$INFORMIXSERVER" = x ]; then
echo This file must be run from within an IDS environment
exit 1
fi
export DB_LOCALE=zh_TW.big5
export CLIENT_LOCALE=zh_TW.big5
export DBDATE=MDY3/C1
export DBCENTURY=R
cat minguo.sql | dbaccess - -
export DBCENTURY=P
cat minguo.sql | dbaccess - -
export DBCENTURY=F
cat minguo.sql | dbaccess - -
export DBCENTURY=C
cat minguo.sql | dbaccess - -
minguo.sql:
drop database zhtw;
create database zhtw;
create table t1(c1 date);
insert into t1 values('08/08/99');
insert into t1 values('08/08/02');
insert into t1 values('080848') ;
insert into t1 values('080852') ;
select * from t1;