LunarDate.Date¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class LunarDate.Date(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- classmethod check_version(required_major, required_minor, required_micro)¶
- Parameters:
- Returns:
None
if theLunarDate.Date
library is compatible with the given version, or a string describing the version mismatch. The returned string is owned byLunarDate.Date
and must not be modified or freed.- Return type:
Checks that the
LunarDate.Date
library in use is compatible with the given version. Generally you would pass in the constantsLunarDate.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 ofLunarDate.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:
Allocates a
LunarDate.Date
and initializes it. Free the return value withLunarDate.Date.free
().New in version 2.4.0.
- free()¶
Frees a
LunarDate.Date
returned fromLunarDate.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:
Returns the string about the date, used to show in calendar.
New in version 3.0.0.
- get_holiday(delimiter)¶
- Parameters:
delimiter (
str
) – used to join the holidays.- Returns:
a newly-allocated holiday string of the date or
None
.- Return type:
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:
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:
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 toTrue
.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:
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:
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.