LunarDate.Date

g GObject.Object GObject.Object LunarDate.Date LunarDate.Date GObject.Object->LunarDate.Date

Subclasses:None

Methods

Inherited:GObject.Object (37)
Structs:GObject.ObjectClass (5)
class check_version (required_major, required_minor, required_micro)
class new ()
  free ()
  get_jieri (delimiter)
  set_lunar_date (year, month, day, hour, isleap)
  set_solar_date (year, month, day, hour)
  strftime (format)

Virtual Methods

Inherited:GObject.Object (7)

Properties

None

Signals

Inherited:GObject.Object (1)

Fields

Inherited:GObject.Object (1)
Name Type Access Description
object GObject.Object r  

Class Details

class LunarDate.Date(**kwargs)
Bases:GObject.Object
Abstract:No
Structure:LunarDate.DateClass

All of these fields should be considered read-only.

classmethod check_version(required_major, required_minor, required_micro)
Parameters:
  • required_major (int) – the required major version.
  • required_minor (int) – the required minor version.
  • required_micro (int) – the required micro version.
Returns:

None if the LunarDate.Date library is compatible with the given version, or a string describing the version mismatch. The returned string is owned by LunarDate.Date and must not be modified or freed.

Return type:

str

Checks that the LunarDate.Date library in use is compatible with the given version. Generally you would pass in the constants LunarDate.DATE_MAJOR_VERSION, LunarDate.DATE_MINOR_VERSION, LunarDate.DATE_MICRO_VERSION as the three arguments to this function; that produces a check that the library in use is compatible with the version of LunarDate.Date the application or module was compiled against.

Compatibility is defined by two things: first the version of the running library is newer than the version required_major.required_minor.`required_micro`. Second the running library must be binary compatible with the version required_major.required_minor.`required_micro` (same major version.)

New in version 2.4.0.

classmethod new()
Returns:a newly-allocated LunarDate.Date
Return type:LunarDate.Date

Allocates a LunarDate.Date and initializes it. Free the return value with LunarDate.Date.free().

free()

Frees a LunarDate.Date returned from LunarDate.Date.new().

get_jieri(delimiter)
Parameters:delimiter (str) – 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.
Return type:str

Returns the all holiday of the date, joined with the delimiter. The date must be valid.

set_lunar_date(year, month, day, hour, isleap)
Parameters:
  • year (int) – year to set.
  • month (GLib.DateMonth) – month to set.
  • day (int) – day to set.
  • hour (int) – hour to set.
  • isleap (bool) – indicate whether the month is a leap month.
Raises:

GLib.Error

Sets the lunar year, month, day and the hour for a LunarDate.Date. If the month is a leap month, you should set the isleap to True.

set_solar_date(year, month, day, hour)
Parameters:
  • year (int) – year to set.
  • month (GLib.DateMonth) – month to set.
  • day (int) – day to set.
  • hour (int) – hour to set.
Raises:

GLib.Error

Sets the solar year, month, day and the hour for a LunarDate.Date.

strftime(format)
Parameters:format (str) – specify the output format. this
Returns:a newly-allocated output string, nul-terminated
Return type:str

使用给定的格式来输出字符串。类似于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 文件即可。