debian/0000755000000000000000000000000012242726365007177 5ustar debian/copyright0000644000000000000000000000416412223230473011124 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Lunar Upstream-Contact: Fung F. Lee Source: http://web.archive.org/web/20051027042122/http://umunhum.stanford.edu/~lee/chicomp/chicomp.html Files: * Copyright: 1988,1989,1991,1992,2001 Fung F. Lee and Ricky Yeung License: GPL-2+ Files: debian/* Copyright: 2002, 2006, 2013 Anthony Fok License: GPL-2+ Files: lunar.c lunar.1 Makefile Copyright: 1988,1989,1991,1992,2001 Fung F. Lee and Ricky Yeung 2002, 2006, 2013 Anthony Fok License: GPL-2+ Files: tables.h Copyright: 1988,1989,1991,1992,2001 Fung F. Lee and Ricky Yeung 1992 Hwei Chen Ti License: GPL-2+ Files: lunar.bitmap Copyright: 1991? Weimin Liu License: GPL-2+ License: GPL-2+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA . The last version of this program was released on July 23, 1992 as version 2.1a. This program was first released under the terms of GNU GPL on October 28, 2001 as version 2.2. Both versions are identical except for the license text. . The complete text of the GNU General Public License can be found in "/usr/share/common-licenses/GPL" on your Debian system. debian/watch0000644000000000000000000000041012223211111010174 0ustar version=3 # http://umunhum.stanford.edu/~lee/chicomp/chicomp.html \ # (?:.*/)?lunar-(\d[\d\.]*)\.tar\.(?:gz|bz2|xz) http://web.archive.org/web/20051027042122/http://umunhum.stanford.edu/~lee/chicomp/chicomp.html \ (?:.*/)?lunar-(\d[\d\.]*)\.tar\.(?:gz|bz2|xz) debian/source/0000755000000000000000000000000012221627021010461 5ustar debian/source/format0000644000000000000000000000001412221627021011667 0ustar 3.0 (quilt) debian/rules0000755000000000000000000000003512223010735010237 0ustar #!/usr/bin/make -f %: dh $@ debian/patches/0000755000000000000000000000000012242724614010621 5ustar debian/patches/20_update_man_page.diff0000644000000000000000000001137512223447245015075 0ustar Description: Update lunar.1 man page with added options Jidanni reported in 2009: . There are options, e.g., --utf8, on --help that are not documented on the man page. Indeed, also mention --help itself. . In October 2013, I finally worked on the man page to document the new options and changes as found in the Debian version of lunar 2.2-4. Origin: vendor Author: Anthony Fok Bug-Debian: http://bugs.debian.org/514069 Last-Update: 2013-10-04 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/lunar.1 +++ b/lunar.1 @@ -1,29 +1,41 @@ -.TH lunar 1 "28 October 2001" +.TH LUNAR 1 "4 October 2013" "Lunar version 2.2-4 (Debian)" +. .SH NAME -lunar (version 2.2) \- a calendar conversion utility -.SH SYNTAX -.B lunar -[ -.B\-h -] [ -.B\-b -] [ -.B\-i -] [ -.B\-l -] -.I year month day -[ -.I hour -] +lunar \- a calendar conversion utility +. +.SH SYNOPSIS +. +.SY lunar +.OP \-usthg5b +. +.SY lunar +.OP \-usthg5b +.I year +.I month +.I day +.RI [ hour ] +. +.SY lunar +.OP \-usthg5b +.B \-i +.OP \-l +.I year +.I month +.I day +.RI [ hour ] +. +.SY lunar +.B \-\-help +.YS +. .SH DESCRIPTION The -.PN lunar +.I lunar program performs date conversion between the Gregorian Solar Calendar (SC) and the Chinese Lunar Calendar (LC). Given a date in either calendar, the program also -outputs the corresponding "shengxiao" (animal of the year) -and "ganzhi" characters. +outputs the corresponding "\fIsheng\%xiao\fR" (animal of the year) +and "\fIganzhi\fR" characters. The date range currently covered is from about 1900 A.D. to 2049 A.D. .PP For the sake of convenience, we choose the convention such that the solar @@ -39,7 +51,7 @@ and SC 1991.2.16.1 is LC 1991.1.2.1. The standard time of the Lunar Calendar is Beijing (Hong Kong) Standard Time, not GMT. Be sure to adjust appropriately for other time zones -and "Day-light Saving Time". +and "Daylight Saving Time". .PP In the Lunar Calendar, a normal year has 12 months, and a leap year (run-nian) has 13 months, @@ -49,23 +61,63 @@ is called the 6-th leap month. A (leap) month is either a short or long one, which has 29 or 30 days respectively. .PP -There are 10 gan's and 12 zhi's. -The ganzhi labeling of the year, month, day and hour of a date +There are 10 \fIgan\fR's and 12 \fIzhi\fR's. +The \fIganzhi\fR labeling of the year, month, day and hour of a date is a member of the Cartesian product GxGxGxG, where G = {1,2,...,60}. -For example, "jia-zi" is 1, "yi-chou" is 2, and so on. -The ganzhi of the j-th leap month is the same as that of the j-th month. - +For example, "\fIjia-zi\fR" is 1, "\fIyi-chou\fR" is 2, and so on. +The \fIganzhi\fR of the j-th leap month is the same as that of the j-th month. +. +.SH OPTIONS +.P +Since +.I lunar +was first packaged for Debian in 2002, the Debian package maintainer +has made minor additions such as Big5 and UTF-8 support. +More recently, +.I lunar +gained the ability to detect system locale and choose the correct +character set. +.P +.I Lunar +now also detects and displays the current China Standard Time by default, +so that the +.I year +.I month +.I day +.RI [ hour ] +parameters are now optional for solar-to-lunar calendar conversion. +.P The possible options are -.IP b -output ganzhi in special "bitmap" characters. -.IP h -output hanzi or Chinese characters encoded in (highest-bit-set) GB code. -.IP i +.TP +.B \-b +output \fIganzhi\fR in special "bitmap" characters. +.TP +\fB\-u\fR, \fB\-\-utf8\fR +output \fIhanzi\fR or Chinese characters encoded in UTF-8. +.TP +.B \-s +output simplified Chinese (for UTF-8 only). +.TP +.B \-t +output traditional Chinese (for UTF-8 only). +.TP +\fB\-g\fR, \fB\-h\fR, \fB\-\-gb\fR +output \fIhanzi\fR or Chinese characters encoded in (highest-bit-set) GB code. +.TP +\fB\-5\fR, \fB\-\-big5\fR +output \fIhanzi\fR or Chinese characters encoded in Big5. +.TP +.B \-i convert a lunar date to solar date. The default is to convert a solar date to a lunar date. -.IP l +.TP +.B \-l indicate the month is a lunar leap month. -This option is meaningful only when the "-i" option is used. +This option is meaningful only when the "\-i" option is used. +.TP +.B \-\-help +Print a help message. +. .SH COPYRIGHT Copyright (C) 1988, 1989, 1991, 1992, 2001 Fung F. Lee and Ricky Yeung .sp @@ -88,15 +140,17 @@ version 2.1a. This program was first re GNU GPL on October 28, 2001 as version 2.2. Both versions are identical except for the license text. - .SH AUTHORS Fung F. Lee and Ricky Yeung +. .SH ACKNOWLEDGEMENT The special "bitmap" file "lunar.bitmap" was contributed by Weimin Liu. Special thanks to Hwei Chen Ti who extended the tables from 2001 to 2049. +. .SH BUGS Bug reports and comments should be sent to lee@umunhum.stanford.edu. +. .SH DISCLAIMER This software has no connection with our employers. debian/patches/02_fix_compiler_warnings.diff0000644000000000000000000000414512223451450016342 0ustar Description: Fix GCC compiler warnings found in lunar.c Revise lunar.c to remove GCC compiler warnings such as: . * implicit declaration of function ‘CmpDate’ * implicit declaration of function ‘exit’ * incompatible implicit declaration of built-in function ‘exit’ * unused variable ‘d’ * suggest parentheses around ‘&&’ within ‘||’ * variable ‘nYear’ set but not used . First applied since 2.2-1; revised in 2.2-3 and 2.2-4. Author: Anthony Fok Origin: vendor Last-Update: 2013-10-04 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/lunar.c +++ b/lunar.c @@ -64,6 +64,7 @@ References: #include +#include #include /* "Bitmap" constants */ @@ -150,7 +151,7 @@ long Solar2Day(), Solar2Day1(), Lunar void Day2Lunar(), Day2Solar(); int make_yday(), make_mday(), GZcycle(); void CalGZ(); -int JieDate(), JieDate(); +int CmpDate(), JieDate(); void readBM(), display3(); void Report(), ReportE(), ReportBM(), ReportGB(); void usage(), Error(); @@ -243,9 +244,7 @@ void usage() void Solar2Lunar() { - long offset; - Date *d; offset = Solar2Day(&solar); solar.weekday = (offset + SolarFirstDate.weekday) % 7; @@ -269,7 +268,6 @@ void Lunar2Solar() { long offset; int adj; - Date *d; /* A solar day begins at 12 a.m. */ adj = (lunar.hour == 23)? -1 : 0; @@ -286,7 +284,7 @@ void Lunar2Solar() } -#define LeapYear(y) (((y)%4==0) && ((y)%100!=0) || ((y)%400==0)) +#define LeapYear(y) ((((y)%4==0) && ((y)%100!=0)) || ((y)%400==0)) #define BYEAR 1201 /* BYEAR % 4 == 1 and BYEAR % 400 == 1 for easy calculation of leap years */ /* assert(BYEAR <= SolarFirstDate.year) */ @@ -328,9 +326,8 @@ long Lunar2Day(d) Date *d; { long offset = 0; - int year, i, m, nYear, leapMonth; + int year, i, m, leapMonth; - nYear = make_yday(); year = d->year - LunarFirstDate.year; for (i=0; i Origin: other, http://bugs.debian.org/162634 Bug-Debian: http://bugs.debian.org/162634 Reviewed-by: Anthony Fok Last-Update: 2013-10-04 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/lunar.c +++ b/lunar.c @@ -142,7 +142,7 @@ int jieAlert; /* if there is uncertaint int showHZ = 0; /* output in hanzi */ int showBM = 0; /* output in bitmap */ -char BMfile[] = "lunar.bitmap"; /* bit map file */ +char BMfile[] = "/usr/share/lunar/lunar.bitmap"; /* bit map file */ char GZBM[NBM][BMRow][BMCol]; /* the bitmap array */ char *progname; debian/patches/06_use_locale_and_current_date.diff0000644000000000000000000000765612241217161017463 0ustar Description: Use current locale and system time for display by default I was getting too lazy to type out the long string of parameters to manually set the output character set and the full date every time I wanted to check the current date in Lunar calendar, hence this patch. It was also a good little exercise to brush up my C programming skill. :-) . First applied in 2.2-4. Author: Anthony Fok Origin: vendor Last-Update: 2013-11-15 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/lunar.c +++ b/lunar.c @@ -1,6 +1,6 @@ /* $Id: lunar.c,v 1.6 2001/10/29 05:55:39 fflee Exp $ */ -char version[] = "Lunar Version 2.2 (October 28, 2001)"; +char version[] = "Lunar Version 2.2-4 (Debian) (October 4, 2013)"; /*---------------------------------------------------------------------------- @@ -66,6 +66,7 @@ References: #include #include #include +#include /* "Bitmap" constants */ #define BMRow 7 /* number of rows for each bitmap */ @@ -212,10 +213,56 @@ char *argv[]; { int year, month, day, hour, i, k, option, inverse=0, leap=0; int dateInfo[4]; + time_t cur_time; + struct tm *now; + char *locale, *s; + char *language, *territory, *codeset; progname = "lunar"; printf("%s\n\n", version); + locale = getenv("LC_ALL"); + if (locale == NULL) + locale = getenv("LANG"); + if (locale) + { + /* Form: language[_territory][.codeset][@modifier] */ + s = strdup(locale); + language = strsep(&s, "_.@"); + s = strdup(locale); + strsep(&s, "_"); + territory = strsep(&s, "_.@"); + s = strdup(locale); + strsep(&s, "."); + codeset = strsep(&s, ".@"); +#if 0 + s = strdup(locale); + strsep(&s, "@"); + char *modifier = strsep(&s, "@"); + + printf("%s_%s.%s@%s\n", language, territory, codeset, modifier); +#endif + if (codeset) + { + if (!strcasecmp(codeset, "UTF-8") || !strcasecmp(codeset, "utf8")) + { + if (!strcmp(language, "zh") || + !strcmp(language, "ja") || + !strcmp(language, "ko")) + showHZ_UTF8 = 1; + if (territory && + (!strcmp(territory, "CN") || !strcmp(territory, "SG"))) + simplified = 1; + } + else if (!strcasecmp(codeset, "GB2312") || + !strcasecmp(codeset, "GBK") || + !strcasecmp(codeset, "GB18030")) + showHZ_GB = 1; + else if (!strncasecmp(codeset, "Big5", 4)) + showHZ_B5 = 1; + } + } + for (k=1; k= 3) && (argc - k <= 4))) usage(); - dateInfo[3] = 0; - for (i=0; ktm_year + 1900; + month = now->tm_mon + 1; + day = now->tm_mday; + hour = now->tm_hour; + } + break; + case 3: + case 4: + dateInfo[3] = 0; + for (i=0; k=Cyear && year=1 && month<=12)) @@ -314,7 +385,7 @@ char *argv[]; void usage() { printf("Usage:\n\n"); - printf("Solar->Lunar:\t%s [-h] [-b] year month day [hour]\n", progname); + printf("Solar->Lunar:\t%s [-u] [-h] [-b] [year month day [hour]]\n", progname); printf("\t\t(in Solar Calendar, 24 hour clock)\n\n"); printf("Lunar->Solar:\t%s [-u] [-h] [-b] -i [-l] year month day [hour]\n", progname); debian/patches/10_complete_the_makefile.diff0000644000000000000000000000201112223446435016253 0ustar Description: Complete the Makefile so debian/rules can truly be minimal The special provisions in previous debian/rules are now moved into the upstream Makefile. . Also, the explicit compilation rules in Makefile are removed so that compiler flags set by dpkg-buildflags may get through. Origin: vendor Author: Anthony Fok Last-Update: 2013-10-04 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/Makefile +++ b/Makefile @@ -20,9 +20,22 @@ # CFLAGS= -O -lunar: lunar.o - cc -o lunar lunar.o +all: lunar clean: - rm *.o + rm -f *.o lunar +PREFIX = /usr +BINDIR = $(PREFIX)/bin +DATADIR = $(PREFIX)/share +MANDIR = $(PREFIX)/share/man + +install: lunar lunar.1 + install -m755 -d $(DESTDIR)$(BINDIR) + install -m755 -p lunar $(DESTDIR)$(BINDIR)/ + install -m755 -d $(DESTDIR)$(DATADIR)/lunar + install -m644 -p lunar.bitmap $(DESTDIR)$(DATADIR)/lunar/ + install -m755 -d $(DESTDIR)$(MANDIR)/man1 + install -m644 -p lunar.1 $(DESTDIR)$(MANDIR)/man1/ + +.PHONY: install clean debian/patches/07_fix_segfault_aggressive-loop-optimizations.diff0000644000000000000000000000204512242724613022536 0ustar Description: Fix "lunar -b" segfault when compiled with -O2 in gcc-4.8 lunar.bitmap contained a line that was too long with extraneous trailing spaces, causing an overflow the array in readBM(), but did not ause any visible error previously. . When compiled with GCC 4.8, however, this bug results in segmentation fault, probably due to the new aggressive loop optimizations used in -O2 and -O3. . See http://blog.regehr.org/archives/918 for a different but related issue. Origin: vendor Author: Anthony Fok Last-Update: 2013-11-20 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/lunar.bitmap +++ b/lunar.bitmap @@ -21,7 +21,7 @@ _|___|____ |_____| | |-| --|-- -|_| ---`--- +|_| ---`--- | | ____|__ |-| \ | | --- a/lunar.c +++ b/lunar.c @@ -978,7 +978,7 @@ void readBM() { c = getc(fp); if ((c==EOF) || (c=='\n')) break; - GZBM[i][j][k++] = c; + if (k Author: LI Daobing Origin: vendor, http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=12;filename=lunar-2.2-3.1-nmu.diff;att=1;bug=366918 Bug-Debian: http://bugs.debian.org/366918 Reviewed-By: LI Daobing Reviewed-By: Alexander Reichle-Schmehl Last-Update: 2013-10-03 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/tables.h +++ b/tables.h @@ -86,7 +86,7 @@ static long yearInfo[Nyear] = { 0x0a5b0, 0x15176, 0x052b0, 0x0a930, 0x07954, /* 2020 */ 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, /* 2025 */ 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, 0x05aa0, /* 2030 */ - 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, /* 2035 */ + 0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0, /* 2035 */ 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, 0x0b5a0, /* 2040 */ 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, /* 2045 */ 0x0aa50, 0x1b255, 0x06d20, 0x0ada0 /* 2049 */ debian/patches/04_add_big5_and_utf8_output.diff0000644000000000000000000002253512223451512016624 0ustar Description: Add Big5 and UTF-8 output options for lunar.c Big5 support was added to 2.2-1 in 2002. . UTF-8 support was added to 2.2-3 at the request of LI Daobing in 2006, see Debian Bug#288170. However, it could only print simplified Chinese in UTF-8 mode back then. . In 2013, two new options, -s and -t, were added to 2.2-4 so that the end-user may choose either simplified or traditional Chinese in UTF-8 mode. Author: Anthony Fok Origin: vendor Bug-Debian: http://bugs.debian.org/288170 Last-Update: 2013-10-04 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/lunar.c +++ b/lunar.c @@ -112,6 +112,31 @@ static char *weekday[] = { "Thursday", "Friday", "Saturday" }; +static char *GanUTF8[] = { + "甲", "乙", "丙", "丁", "戊", + "己", "庚", "辛", "壬", "癸" +}; + +static char *ZhiUTF8[] = { + "子", "丑", "寅", "卯", "辰", "巳", + "午", "未", "申", "酉", "戌", "亥" +}; + +static char *ShengXiaoUTF8_hant[] = { + "鼠", "牛", "虎", "兔", "龍", "蛇", + "馬", "羊", "猴", "雞", "狗", "豬" +}; + +static char *ShengXiaoUTF8_hans[] = { + "鼠", "牛", "虎", "兔", "龙", "蛇", + "马", "羊", "猴", "鸡", "狗", "猪" +}; + +static char *weekdayUTF8[] = { + "日", "一", "二", "三", + "四", "五", "六" +}; + static char *GanGB[] = { "", "", "", "", "", "", "", "", "", "" @@ -132,6 +157,26 @@ static char *weekdayGB[] = { "", "", "" }; +static char *GanB5[] = { + "", "A", "", "B", "", + "v", "", "", "", "" +}; + +static char *ZhiB5[] = { + "l", "", "G", "f", "", "x", + "", "", "", "", "", "" +}; + +static char *ShengXiaoB5[] = { + "", "", "", "", "s", "D", + "", "", "U", "", "", "" +}; + +static char *weekdayB5[] = { + "", "@", "G", "T", + "|", "", "" +}; + Date solar, lunar, gan, zhi, gan2, zhi2, lunar2; @@ -140,8 +185,11 @@ int yday[Nyear]; /* number of lunar days int mday[Nmonth+1]; /* number of days in the months of the lunar year */ int jieAlert; /* if there is uncertainty in JieQi calculation */ -int showHZ = 0; /* output in hanzi */ +int showHZ_GB = 0; /* output in GB-encoded hanzi */ int showBM = 0; /* output in bitmap */ +int showHZ_UTF8 = 0; /* output in UTF-8-encoded hanzi */ +int showHZ_B5 = 0; /* output in Big5-encoded hanzi */ +int simplified = 0; /* output in simplified Chinese */ char BMfile[] = "/usr/share/lunar/lunar.bitmap"; /* bit map file */ char GZBM[NBM][BMRow][BMCol]; /* the bitmap array */ char *progname; @@ -153,7 +201,8 @@ int make_yday(), make_mday(), GZcycl void CalGZ(); int CmpDate(), JieDate(); void readBM(), display3(); -void Report(), ReportE(), ReportBM(), ReportGB(); +void Report(), ReportE(), ReportBM(), ReportGB(), ReportB5(); +void ReportUTF8_hant(), ReportUTF8_hans(); void usage(), Error(); @@ -174,8 +223,45 @@ char *argv[]; { case 'i': inverse = 1; break; case 'l': if (inverse) leap=1; else usage(); break; - case 'h': showHZ = 1; break; - case 'b': showBM = 1; break; + case 'g': + case 'h': showHZ_GB = 1; + showHZ_UTF8 = showHZ_B5 = 0; + break; + case 'b': showBM = 1; + showHZ_UTF8 = showHZ_GB = showHZ_B5 = 0; + break; + case 'u': showHZ_UTF8 = 1; + showHZ_B5 = showHZ_GB = 0; + break; + case '5': showHZ_B5 = 1; + showHZ_UTF8 = showHZ_GB = 0; + break; + case 's': simplified = 1; break; + case 't': simplified = 0; break; + case '-': + if (!strcmp(argv[k], "--utf8")) + { + showHZ_UTF8 = 1; + showHZ_B5 = 0; + showHZ_GB = 0; + } + else if (!strcmp(argv[k], "--big5")) + { + showHZ_B5 = 1; + showHZ_UTF8 = 0; + showHZ_GB = 0; + } + else if (!strcmp(argv[k], "--gb")) + { + showHZ_GB = 1; + showHZ_UTF8 = 0; + showHZ_B5 = 0; + } + else if (!strcmp(argv[k], "--help")) + usage(); + else + usage(); + break; default: usage(); break; } } @@ -230,12 +316,16 @@ void usage() printf("Usage:\n\n"); printf("Solar->Lunar:\t%s [-h] [-b] year month day [hour]\n", progname); printf("\t\t(in Solar Calendar, 24 hour clock)\n\n"); - printf("Lunar->Solar:\t%s [-h] [-b] -i [-l] year month day [hour]\n", + printf("Lunar->Solar:\t%s [-u] [-h] [-b] -i [-l] year month day [hour]\n", progname); printf("\t\t(in Lunar Calendar, 24 hour clock)\n"); - printf("\t\t-l means the month is a leap month (\"run4 yue4\")\n\n"); - printf("\t\t-h means output in hanzi (GB)\n"); - printf("\t\t-b means output in \"bitmap\"\n\n"); + printf("\t\t-l means the month is a leap month (\"run4 yue4\")\n\n"); + printf("\t\t-u, --utf8 means output in hanzi (UTF-8)\n"); + printf("\t\t -s selects simplified Chinese for UTF-8\n"); + printf("\t\t -t selects traditional Chinese for UTF-8\n"); + printf("\t\t-h, --gb means output in hanzi (GB)\n"); + printf("\t\t-5, --big5 means output in hanzi (Big5)\n\n"); + printf("\t\t-b means output in \"bitmap\"\n"); printf("Date range: about %d years from the Solar Date %d.%d.%d\n", Nyear, SolarFirstDate.year, SolarFirstDate.month, SolarFirstDate.day); exit(1); @@ -586,7 +676,16 @@ int year; void Report() { - if (showHZ) + if (showHZ_UTF8) + { + if (simplified) + ReportUTF8_hans(); + else + ReportUTF8_hant(); + } + else if (showHZ_B5) + ReportB5(); + else if (showHZ_GB) ReportGB(); else if (showBM) ReportBM(); @@ -595,6 +694,72 @@ void Report() } +void ReportUTF8_hant() +{ + printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "陽曆: ", + solar.year, "年", solar.month, "月", solar.day, + "日", solar.hour, "時 ", + "星期", weekdayUTF8[solar.weekday]); + printf("%s%d%s%s%2d%s%2d%s%s%s%s%s\n", "陰曆: ", + lunar.year, "年", (lunar.leap? "閏":""), + lunar.month, "月", lunar.day, "日", + ZhiUTF8[zhi.hour], "時 ", + "生肖屬", ShengXiaoUTF8_hant[zhi.year]); + printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", "干支: ", + GanUTF8[gan.year], ZhiUTF8[zhi.year], "年 ", + GanUTF8[gan.month], ZhiUTF8[zhi.month], "月 ", + GanUTF8[gan.day], ZhiUTF8[zhi.day], "日 ", + GanUTF8[gan.hour], ZhiUTF8[zhi.hour], "時 "); + printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + "用四柱神算推算之時辰八字: ", + GanUTF8[gan2.year], ZhiUTF8[zhi2.year], "年 ", + GanUTF8[gan2.month], ZhiUTF8[zhi2.month], "月 ", + GanUTF8[gan2.day], ZhiUTF8[zhi2.day], "日 ", + GanUTF8[gan2.hour], ZhiUTF8[zhi2.hour], "時 "); + if (jieAlert) + { + printf("* %s, %s\n", "是日為節", + "月柱可能要修改"); + if (lunar2.month==1) + printf("* %s\n", "年柱亦可能要修改"); + printf("* %s\n", "請查有節氣時間之萬年曆"); + } +} + + +void ReportUTF8_hans() +{ + printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "阳历: ", + solar.year, "年", solar.month, "月", solar.day, + "日", solar.hour, "时 ", + "星期", weekdayUTF8[solar.weekday]); + printf("%s%d%s%s%2d%s%2d%s%s%s%s%s\n", "阴历: ", + lunar.year, "年", (lunar.leap? "闰":""), + lunar.month, "月", lunar.day, "日", + ZhiUTF8[zhi.hour], "时 ", + "生肖属", ShengXiaoUTF8_hans[zhi.year]); + printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", "干支: ", + GanUTF8[gan.year], ZhiUTF8[zhi.year], "年 ", + GanUTF8[gan.month], ZhiUTF8[zhi.month], "月 ", + GanUTF8[gan.day], ZhiUTF8[zhi.day], "日 ", + GanUTF8[gan.hour], ZhiUTF8[zhi.hour], "时 "); + printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + "用四柱神算推算之时辰八字: ", + GanUTF8[gan2.year], ZhiUTF8[zhi2.year], "年 ", + GanUTF8[gan2.month], ZhiUTF8[zhi2.month], "月 ", + GanUTF8[gan2.day], ZhiUTF8[zhi2.day], "日 ", + GanUTF8[gan2.hour], ZhiUTF8[zhi2.hour], "时 "); + if (jieAlert) + { + printf("* %s, %s\n", "是日为节", + "月柱可能要修改"); + if (lunar2.month==1) + printf("* %s\n", "年柱亦可能要修改"); + printf("* %s\n", "请查有节气时间之万年历"); + } +} + + void ReportGB() { printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "", @@ -627,6 +792,39 @@ void ReportGB() } } + +void ReportB5() +{ + printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "G@", + solar.year, "~", solar.month, "", solar.day, + "", solar.hour, "ɡ@", + "P", weekdayB5[solar.weekday]); + printf("%s%d%s%s%2d%s%2d%s%s%s%s%s\n", "G@", + lunar.year, "~", (lunar.leap? "|":""), + lunar.month, "", lunar.day, "", + ZhiB5[zhi.hour], "ɡ@", + "ͨv", ShengXiaoB5[zhi.year]); + printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", "zG@", + GanB5[gan.year], ZhiB5[zhi.year], "~@", + GanB5[gan.month], ZhiB5[zhi.month], "@", + GanB5[gan.day], ZhiB5[zhi.day], "@", + GanB5[gan.hour], ZhiB5[zhi.hour], "ɡ@"); + printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + "Υ|W⤧ɨKrG@", + GanB5[gan2.year], ZhiB5[zhi2.year], "~@", + GanB5[gan2.month], ZhiB5[zhi2.month], "@", + GanB5[gan2.day], ZhiB5[zhi2.day], "@", + GanB5[gan2.hour], ZhiB5[zhi2.hour], "ɡ@"); + if (jieAlert) + { + printf("* %s, %s\n", "O鬰`", + "Winק"); + if (lunar2.month==1) + printf("* %s\n", "~Winק"); + printf("* %s\n", "Ьd`ɶU~"); + } +} + void ReportE() { debian/patches/01_strip_trailing_whitespace.diff0000644000000000000000000001254512223450447017227 0ustar Description: Strip trailing whitespace from lunar.c First applied in 2.2-4. Author: Anthony Fok Origin: vendor Last-Update: 2013-10-04 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/lunar.c +++ b/lunar.c @@ -12,25 +12,25 @@ char version[] = "Lunar Version 2.2 (Oct # Copyright (C) 1988,1989,1991,1992,2001 Fung F. Lee and Ricky Yeung # -# +# # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# +# # # Revision History: # The last version of this program was released on July 23, 1992 as -# version 2.1a. This program was first released under the terms of +# version 2.1a. This program was first released under the terms of # GNU GPL on October 28, 2001 as version 2.2. Both versions are identical # except for the license text. # @@ -38,19 +38,19 @@ char version[] = "Lunar Version 2.2 (Oct # Please send your comments and suggestions to the authors: # Fung F. Lee lee@umunhum.stanford.edu # Ricky Yeung cryeung@hotmail.com -# +# # The special "bitmap" file "lunar.bitmap" was contributed # by Weimin Liu (weimin@alpha.ece.jhu.edu). # # Special thanks to Hwei Chen Ti (chetihc@nuscc.nus.sg or -# chetihc@nusvm.bitnet) who extended the tables from 2001 to 2049. +# chetihc@nusvm.bitnet) who extended the tables from 2001 to 2049. # ----------------------------------------------------------------------------*/ /* This document contains Highest-bit-set GuoBiao (HGB) code, as adopted by CCDOS on IBM PC compatibles, ChineseTalk 6.0 (GB version) on Macintosh, -and cxterm on UNIX and X window. Hence, one may need to transfer this +and cxterm on UNIX and X window. Hence, one may need to transfer this document as a **binary** file. References: @@ -60,7 +60,7 @@ References: ƽԡ 3. Da1zhong4 wan4nian2li4. -*/ +*/ #include @@ -162,7 +162,7 @@ char *argv[]; { int year, month, day, hour, i, k, option, inverse=0, leap=0; int dateInfo[4]; - + progname = "lunar"; printf("%s\n\n", version); @@ -223,7 +223,7 @@ char *argv[]; Report(); exit(0); } - + void usage() { printf("Usage:\n\n"); @@ -249,7 +249,7 @@ void Solar2Lunar() offset = Solar2Day(&solar); solar.weekday = (offset + SolarFirstDate.weekday) % 7; - + /* A lunar day begins at 11 p.m. */ if (solar.hour == 23) offset++; @@ -343,7 +343,7 @@ Date *d; } for (m=1; mmonth; m++) offset += mday[m]; - if (leapMonth && + if (leapMonth && ((d->month>leapMonth) || (d->leap && (d->month==leapMonth)))) offset += mday[m++]; offset += d->day - 1; @@ -360,7 +360,7 @@ Date *d; { int i, m, nYear, leapMonth; - + nYear = make_yday(); for (i=0; i 0; i++) offset -= yday[i]; @@ -403,7 +403,7 @@ Date *d; /* offset is now the number of days from SolarFirstDate.year.1.1 */ for (i=SolarFirstDate.year; - (i 0); i++) + (i 0); i++) offset -= 365 + LeapYear(i); if (offset<0) { @@ -412,7 +412,7 @@ Date *d; } if (i==(SolarFirstDate.year + Nyear)) Error("Year out of range."); d->year = i; - + /* assert(offset<(365+LeapYear(i))); */ for (m=1; m<=12; m++) { @@ -439,14 +439,14 @@ int g, z; if (gz >= 60) printf("internal error\n"); return gz+1; } - + void CalGZ(offset, d, g, z) long offset; Date *d, *g, *z; { int year, month; - + year = d->year - LunarFirstDate.year; month = year * 12 + d->month - 1; /* leap months do not count */ @@ -520,7 +520,7 @@ int make_yday() { int year, i, leap; long code; - + for (year = 0; year < Nyear; year++) { code = yearInfo[year]; @@ -550,7 +550,7 @@ int year; { int i, leapMonth; long code; - + code = yearInfo[year]; leapMonth = code & 0xf; /* leapMonth == 0 means no leap month */ @@ -566,7 +566,7 @@ int year; } else { - /* + /* There is a leap month (run4 yue4) L in this year. mday[1] contains the number of days in the 1-st month; mday[L] contains the number of days in the L-th month; @@ -604,10 +604,10 @@ void ReportGB() printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "", solar.year, "", solar.month, "", solar.day, "", solar.hour, "ʱ", - "", weekdayGB[solar.weekday]); + "", weekdayGB[solar.weekday]); printf("%s%d%s%s%2d%s%2d%s%s%s%s%s\n", "", lunar.year, "", (lunar.leap? "":""), - lunar.month, "", lunar.day, "", + lunar.month, "", lunar.day, "", ZhiGB[zhi.hour], "ʱ", "Ф", ShengXiaoGB[zhi.year]); printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", "֧", debian/compat0000644000000000000000000000000212222537634010372 0ustar 9 debian/changelog0000644000000000000000000000535712242726172011057 0ustar lunar (2.2-4) unstable; urgency=low * Acknowledge NMU on 2.2-3.1. Thanks to CHENG Yuk-Pong for noticing the wrong output on year 2033 and providing an initial patch, and to LI Daobing for providing a corrected patch and NMU. * Use current locale and system time for display by default. Most parameters thus become optional. Saves a lot of typing! :-) * lunar.bitmap contained a line that was too long, and with the new aggressive loop optimizations in GCC 4.8, "lunar -b" would not stop looping when parsing lunar.bitmap, and would eventually result in a segmentation fault. Fixed lunar.bitmap and lunar.c accordingly. * Bump Standards-Version to 3.9.4 * Switch to dpkg-source 3.0 (quilt) format, and split up the patches as follows: - 01_strip_trailing_whitespace.diff - 02_fix_compiler_warnings.diff - 03_add_full_path_to_lunar_bitmap.diff - 04_add_big5_and_utf8_output.diff - 05_fix_output_on_year_2033.diff - 06_use_locale_and_current_date.diff - 07_fix_segfault_aggressive-loop-optimizations.diff - 10_complete_the_makefile.diff - 20_update_man_page.diff * Convert debian/copyright to machine-readable format * Move to dh9-style minimal rules file * Remove explicit compilation target from Makefile (Lintian: W: lunar: hardening-no-relro usr/bin/lunar) * Add "Depends: ${misc:Depends} (Lintian: W: lunar source: debhelper-but-no-misc-depends lunar) * Update upstream URL to the archived copy found on http://web.archive.org/ * Add debian/watch (Lintian: I: lunar source: debian-watch-file-is-missing) * Update man page to reflect the new options added to this Debian version of Lunar. Thanks to Jidanni for the suggestion! (Closes: #514069) -- Anthony Fok Wed, 20 Nov 2013 02:07:41 +0800 lunar (2.2-3.1) unstable; urgency=low * Non-maintainer upload. * FIX: lunar-2.2 wrong output on year 2033 (Closes: #366918) -- LI Daobing Sun, 05 Oct 2008 20:02:16 +0800 lunar (2.2-3) unstable; urgency=low * Added --utf8 option. (Closes: Bug#288170) * Updated Standards-Version: 3.6.2 * [lunar.c]: Added "#include " to remove compiler warnings. -- Anthony Fok Wed, 4 Jan 2006 20:32:25 +0800 lunar (2.2-2) unstable; urgency=medium * Oops, I forgot to install lunar.bitmap and to specify its full path in the source code! Many thanks to Jeronimo Pellegrini for providing the patch to fix the problem. (Closes: Bug#162634) -- Anthony Fok Sat, 19 Oct 2002 02:00:36 +0800 lunar (2.2-1) unstable; urgency=low * Initial Release. * Added Big5 output in addition to the original Hanzi (GB) output. -- Anthony Fok Sun, 22 Sep 2002 14:54:09 +0800 debian/control0000644000000000000000000000131012223131770010562 0ustar Source: lunar Section: utils Priority: optional Maintainer: Anthony Fok Build-Depends: debhelper (>> 9) Standards-Version: 3.9.4 Homepage: http://web.archive.org/web/20051027042122/http://umunhum.stanford.edu/~lee/chicomp/chicomp.html Package: lunar Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: Chinese Lunar Calendar conversion utility The program performs date conversion between the Gregorian Solar Calendar (SC) and the Chinese Lunar Calendar (LC). Given a date in either calendar, the program also outputs the corresponding "shengxiao" animal of the year) and "ganzhi" characters. The date range currently covered is from about 1900 A.D. to 2049 A.D.