![]() |
![]() |
liblunar Reference Manual | ![]() |
|
---|---|---|---|---|
#include <lunar/lunar.h> typedef GDateHour; LUNARDate; #define LUNAR_DATE_ERROR enum LUNARDateError; GQuark lunar_date_error_quark (void); LUNARDate* lunar_date_new (void); void lunar_date_set_solar_date (LUNARDate *date, GDateYear year, GDateMonth month, GDateDay day, GDateHour hour, GError **error); void lunar_date_set_lunar_date (LUNARDate *date, GDateYear year, GDateMonth month, GDateDay day, GDateHour hour, gboolean isleap, GError **error); gchar* lunar_date_get_jieri (LUNARDate *date); gchar* lunar_date_strftime (LUNARDate *date, const char *format); void lunar_date_free (LUNARDate *date);
typedef struct _LUNARDate LUNARDate;
The LUNARDate struct contains only private fields and should not be used directly.
typedef enum { LUNAR_DATE_ERROR_INTERNAL, LUNAR_DATE_ERROR_DAY, LUNAR_DATE_ERROR_YEAR, LUNAR_DATE_ERROR_LEAP } LUNARDateError;
a internal error was found. | |
the day is out of the range. | |
the year is out of the range. | |
the isleap parameter of lunar_date_set_lunar_date() is not corret.
|
LUNARDate* lunar_date_new (void);
Allocates a LUNARDate and initializes it. Free the return value with lunar_date_free()
.
Returns : |
a newly-allocated LUNARDate |
void lunar_date_set_solar_date (LUNARDate *date, GDateYear year, GDateMonth month, GDateDay day, GDateHour hour, GError **error);
Sets the solar year, month, day and the hour for a LUNARDate.
|
a LUNARDate. |
|
year to set. |
|
month to set. |
|
day to set. |
|
hour to set. |
|
location to store the error occuring, or NULL to ignore errors. |
void lunar_date_set_lunar_date (LUNARDate *date, GDateYear year, GDateMonth month, GDateDay day, GDateHour hour, gboolean isleap, GError **error);
Sets the lunar year, month, day and the hour for a LUNARDate. If the month is a leap month, you should set the isleap to TRUE.
gchar* lunar_date_get_jieri (LUNARDate *date);
Returns the holiday of the date. The date must be valid.
|
a LUNARDate |
Returns : |
a newly-allocated holiday string of the date. This can be changed in $(datadir)/liblunar/holiday.dat file. |
gchar* lunar_date_strftime (LUNARDate *date, const char *format);
使用给定的格式来输出字符串。类似于strftime的用法。可使用的格式及输出如下:
%(YEAR)年%(MONTH)月%(DAY)日 公历:大写->二OO八年一月二十一日
%(year)年%(month)月%(day)日 公历:小写->2008年1月21日
%(NIAN)年%(YUE)月%(RI)日%(SHI)时 阴历:大写->丁亥年腊月十四日
%(nian)年%(yue)月%(ri)日%(shi)时 阴历:小写->2007年12月14日
%(Y60)年%(M60)月%(D60)日%(H60)时 干支:大写->丁亥年癸丑月庚申日
%(y60)年%(m60)月%(d60)日%(h60)时 干支:小写 not use
%(Y8)年%(M8)月%(D8)日%(H8)时 八字:大写->丁亥年癸丑月庚申日
%(y8)年%(m8)月%(d8)日%(h8)时 八字:小写 not use
%(shengxiao) 生肖:猪 %(jieri) 节日(节日、纪念日、节气等):立春
使用%(jieri)时,如果此日没有节日或节气,那么将为空。 节日可以自定义,只要按照格式修改$(prefix)/share/liblunar/hodiday.dat即可。
|
a LUNARDate |
|
specify the output format. this |
Returns : |
a newly-allocated output string, nul-terminated |
void lunar_date_free (LUNARDate *date);
Frees a LUNARDate returned from lunar_date_new()
.
|
a LUNARDate |