From t.piyawat at gmail.com Fri May 13 01:13:26 2005 From: t.piyawat at gmail.com (Thawatchai Piyawat) Date: Fri May 13 01:13:29 2005 Subject: LC_TIME for Buddhist Era in Thailand Message-ID: <5a5e08400505130113707b29fe@mail.gmail.com> Hello, I've created a locale th_TH (Thai in Thailand). It can be found in ports/misc/thailocale. Everything seems to work fine so far except a problem in LC_TIME. To solve the problem, I would like to ask everyone the following questions: 1) In Thailand, we use the Buddhist Era that starts 543BC. This year (2005) is the year 2548 in Thailand. The problem is that I can't figure out how to put "plus 543" in the LC_TIME file. 2) I can't find a syntax reference for FreeBSD locale definitions. I've created th_TH by looking at the source of other locales. This method works, but it doesn't give me certainty that what I've done is correct. If such references exist, it would really help me. Thanks, Thawatchai Piyawat From numata at jp.fujitsu.com Fri May 13 03:35:42 2005 From: numata at jp.fujitsu.com (NUMATA Toshinori) Date: Fri May 13 03:35:44 2005 Subject: LC_TIME for Buddhist Era in Thailand In-Reply-To: <5a5e08400505130113707b29fe@mail.gmail.com> References: <5a5e08400505130113707b29fe@mail.gmail.com> Message-ID: <20050513103537.GA22714%numata@jp.fujitsu.com> Hi, Thawatchai Piyawat wrote: > I've created a locale th_TH (Thai in Thailand). It can be found in > ports/misc/thailocale. Everything seems to work fine so far except a > problem in LC_TIME. > > To solve the problem, I would like to ask everyone the following questions: > > 1) In Thailand, we use the Buddhist Era that starts 543BC. This year > (2005) is the year 2548 in Thailand. The problem is that I can't > figure out how to put "plus 543" in the LC_TIME file. I've read the source code of libc's time- and locale-related functions. It seems to me that the current LC_TIME support does not have "era" support. I've read the following files: src/lib/libc/locale/setlocale.c src/lib/libc/stdtime/timelocal.h src/lib/libc/stdtime/timelocal.c and found that the lc_time_T structure defined in timelocal.h (which is used to contain locale-dependent strings for month names, date format, etc.) does not have any era-related members. The Single UNIX Specification, the standard for UNIX systems, defines how to describe era in LC_TIME definition. Currently only commercial UNIX systems such as Solaris and HP-UX have suport of era. The following is the manual for HP-UX: http://docs.hp.com/en/B9106-90011/localedef.4.html Search for "LC_TIME" and see how era definitions are described. > 2) I can't find a syntax reference for FreeBSD locale definitions. > I've created th_TH by looking at the source of other locales. This > method works, but it doesn't give me certainty that what I've done is > correct. If such references exist, it would really help me. I couldn't find such document neither. The format of LC_TIME seems that the file contains lines of text string, each line corresponds to one string entry of lc_time_T structure. For example, the first line corresponds to mon[0] string, the second line to mon[1] string, and so on. The lines that begin with "#" character are comments and will be deleted before installation, so only data lines are included in the installed locale files. Toshinori NUMATA From t.piyawat at gmail.com Fri May 13 13:44:31 2005 From: t.piyawat at gmail.com (Thawatchai Piyawat) Date: Fri May 13 13:44:36 2005 Subject: LC_TIME for Buddhist Era in Thailand In-Reply-To: <20050513103537.GA22714%numata@jp.fujitsu.com> References: <5a5e08400505130113707b29fe@mail.gmail.com> <20050513103537.GA22714%numata@jp.fujitsu.com> Message-ID: <5a5e0840050513134447742c59@mail.gmail.com> Hello Toshinori, Thanks a lot for the information. I read the files you've pointed out and also found that src/lib/libc/locale/nl_langinfo.c has ERA cases that are marked /* XXX: need to be implemented */ So, it's quite sure that ERA hasn't yet been supported in FreeBSD. BTW, glibc supports ERA. A Linux guy in Thailand defined ERA with this statement: %era "+:1:-542/01/01:+*::%N%o" It seems to be the same syntax as in the standard document. Thawatchai On 5/13/05, NUMATA Toshinori wrote: > Hi, > > Thawatchai Piyawat wrote: > > > I've created a locale th_TH (Thai in Thailand). It can be found in > > ports/misc/thailocale. Everything seems to work fine so far except a > > problem in LC_TIME. > > > > To solve the problem, I would like to ask everyone the following questions: > > > > 1) In Thailand, we use the Buddhist Era that starts 543BC. This year > > (2005) is the year 2548 in Thailand. The problem is that I can't > > figure out how to put "plus 543" in the LC_TIME file. > > I've read the source code of libc's time- and locale-related > functions. It seems to me that the current LC_TIME support > does not have "era" support. > > I've read the following files: > > src/lib/libc/locale/setlocale.c > src/lib/libc/stdtime/timelocal.h > src/lib/libc/stdtime/timelocal.c > > and found that the lc_time_T structure defined in timelocal.h > (which is used to contain locale-dependent strings for month > names, date format, etc.) does not have any era-related members. > > The Single UNIX Specification, the standard for UNIX systems, > defines how to describe era in LC_TIME definition. Currently > only commercial UNIX systems such as Solaris and HP-UX have > suport of era. The following is the manual for HP-UX: > > http://docs.hp.com/en/B9106-90011/localedef.4.html > > Search for "LC_TIME" and see how era definitions are described. > > > > 2) I can't find a syntax reference for FreeBSD locale definitions. > > I've created th_TH by looking at the source of other locales. This > > method works, but it doesn't give me certainty that what I've done is > > correct. If such references exist, it would really help me. > > I couldn't find such document neither. The format of LC_TIME > seems that the file contains lines of text string, each line > corresponds to one string entry of lc_time_T structure. For > example, the first line corresponds to mon[0] string, the > second line to mon[1] string, and so on. > > The lines that begin with "#" character are comments and will > be deleted before installation, so only data lines are included > in the installed locale files. > > > Toshinori NUMATA >