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_calendar (max)

get_constellation ()

get_holiday (delimiter)

get_jieri (delimiter)

set_lunar_date (year, month, day, hour, isleap)

set_lunar_holiday (month, day, holiday)

set_solar_date (year, month, day, hour)

set_solar_holiday (month, day, holiday)

set_week_holiday (month, week_of_month, day_of_week, holiday)

strftime (format)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class LunarDate.Date(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

LunarDate.DateClass

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().

New in version 2.4.0.

free()

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

New in version 2.4.0.

get_calendar(max)
Parameters:

max (int) – max length of the returned string.

Returns:

a newly-allocated string of the date or None.

Return type:

str

Returns the string about the date, used to show in calendar.

New in version 3.0.0.

get_constellation()
Return type:

str

get_holiday(delimiter)
Parameters:

delimiter (str) – used to join the holidays.

Returns:

a newly-allocated holiday string of the date or None.

Return type:

str

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

New in version 3.0.0.

get_jieri(delimiter)
Parameters:

delimiter (str) – used to join the holidays.

Returns:

a newly-allocated holiday string of the date or None.

Return type:

str

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

Deprecated since version 3.0.0: Use LunarDate.Date.get_holiday() instead.

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.

New in version 2.4.0.

set_lunar_holiday(month, day, holiday)
Parameters:
  • month (GLib.DateMonth) – Lunar month of the holiday.

  • day (int) – Lunar day of the holiday.

  • holiday (str) – custom holiday string.

Add new holiday by lunar.

New in version 3.0.0.

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.

New in version 2.4.0.

set_solar_holiday(month, day, holiday)
Parameters:
  • month (GLib.DateMonth) – Solar month of the holiday.

  • day (int) – Solar day of the holiday.

  • holiday (str) – custom holiday string.

Add new holiday by solar.

New in version 3.0.0.

set_week_holiday(month, week_of_month, day_of_week, holiday)
Parameters:
  • month (GLib.DateMonth) – Month of the holiday.

  • week_of_month (int) – which week of the month, the first week is 1, range is 1-5.

  • day_of_week (int) – day of the week, 0 for Sunday, 6 for Saturday, range is 0-6.

  • holiday (str) – custom holiday string.

Add new holiday by week.

New in version 3.0.0.

strftime(format)
Parameters:

format (str) – specify the output format.

Returns:

a newly-allocated output string, nul-terminated

Return type:

str

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 LunarDate.Date.get_holiday () to get the output.

New in version 2.4.0.