Method

LunarDateDatestrftime

since: 2.4.0

Declaration [src]

gchar*
lunar_date_strftime (
  LunarDate* date,
  const gchar* format
)

Description [src]

Use the given format to output a string, similar to strftime usage. The available formats and outputs are as follows:

format="%(YEAR)年%(MONTH)月%(DAY)日%(HOUR)时", output="一九一○年二月十九日二时"   //大写公历
format="%(year)年%(month)月%(day)日%(hour)时", output="1910年2月19日2时"          //小写公历
format="%(NIAN)年%(YUE)月%(RI)日%(SHI)时",     output="庚戌年一月初十日丑时"      //大写农历(月份前带"闰"表示闰月)
format="%(nian)年%(yue)月%(ri)日%(shi)时",     output="1910年1月10日2时"          //小写农历(月份前带"*"表示闰月)
format="%(Y60)年%(M60)月%(D60)日%(H60)时",     output="庚戌年戊寅月乙卯日丁丑时"  //干支
format="%(Y8)年%(M8)月%(D8)日%(H8)时",         output="庚戌年戊寅月乙卯日丁丑时"  //八字
format="%(shengxiao)",                        output="狗"                         //生肖
format="%(holiday)",                          output="雨水"                       //节日(节日、纪念日、节气等)

When using %(holiday), the output is automatically truncated to 3 utf8 characters or 4 ascii characters. If you need all the holiday information, please use lunar_date_get_holiday() to get the output.

Available since: 2.4.0

Parameters

format

Type: const gchar*

Specify the output format.

The data is owned by the caller of the method.
The value is a NUL terminated UTF-8 string.

Return value

Type: gchar*

A newly-allocated output string, nul-terminated.

The caller of the method takes ownership of the returned data, and is responsible for freeing it.
The value is a NUL terminated UTF-8 string.