| LunarDate Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | Object Hierarchy | ||||
#include <lunar-date/lunar-date.h> struct LunarDate; enum LunarDateError; LunarDate * lunar_date_new (void); void lunar_date_set_solar_date (LunarDate *date,GDateYear year,GDateMonth month,GDateDay day,guint8 hour,GError **error); void lunar_date_set_lunar_date (LunarDate *date,GDateYear year,GDateMonth month,GDateDay day,guint8 hour,gboolean isleap,GError **error); gchar * lunar_date_get_jieri (LunarDate *date,const gchar *delimiter); gchar * lunar_date_strftime (LunarDate *date,const char *format); void lunar_date_free (LunarDate *date);
typedef enum
{
LUNAR_DATE_ERROR_INTERNAL,
LUNAR_DATE_ERROR_YEAR,
LUNAR_DATE_ERROR_MONTH,
LUNAR_DATE_ERROR_DAY,
LUNAR_DATE_ERROR_HOUR,
LUNAR_DATE_ERROR_LEAP
} LunarDateError;
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,guint8 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,guint8 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,const gchar *delimiter);
Returns the all holiday of the date, joined with the delimiter. The date must be valid.
|
a LunarDate |
|
used to join the holidays. |
Returns : |
a newly-allocated holiday string of the date. This can be changed in $XDG_CONFIG_HOME/liblunar/hodiday.dat file. |
gchar * lunar_date_strftime (LunarDate *date,const char *format);
使用给定的格式来输出字符串。类似于strftime的用法。可使用的格式及输出如下:
%(YEAR)年%(MONTH)月%(DAY)%(HOUR)日 公历:大写->二OO八年一月二十一日
%(year)年%(month)月%(day)%(hour)日 公历:小写->2008年1月21日
%(NIAN)年%(YUE)月%(RI)日%(SHI)时 阴历:大写->丁亥年腊月十四日,(月份前带"闰"表示闰月)
%(nian)年%(yue)月%(ri)日%(shi)时 阴历:小写->2007年12月14日,(月份前带"*"表示闰月)
%(Y60)年%(M60)月%(D60)日%(H60)时 干支:大写->丁亥年癸丑月庚申日
%(Y8)年%(M8)月%(D8)日%(H8)时 八字:大写->丁亥年癸丑月庚申日
%(shengxiao) 生肖:猪 %(jieri) 节日(节日、纪念日、节气等):立春
使用%(jieri)时,如果此日没有节日或节气,那么将为空。 支持自定义节日,只要按照格式修改 $XDG_CONFIG_HOME/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 |