diff --git a/addon/globalPlugins/clipboardEnhancement/_sxtwl.cp311-win32.pyd b/addon/globalPlugins/clipboardEnhancement/_sxtwl.cp311-win32.pyd new file mode 100644 index 0000000..0b57998 Binary files /dev/null and b/addon/globalPlugins/clipboardEnhancement/_sxtwl.cp311-win32.pyd differ diff --git a/addon/globalPlugins/clipboardEnhancement/_sxtwl.cp37-win32.pyd b/addon/globalPlugins/clipboardEnhancement/_sxtwl.cp37-win32.pyd index e61a6f8..0b308d3 100644 Binary files a/addon/globalPlugins/clipboardEnhancement/_sxtwl.cp37-win32.pyd and b/addon/globalPlugins/clipboardEnhancement/_sxtwl.cp37-win32.pyd differ diff --git a/addon/globalPlugins/clipboardEnhancement/calendar.py b/addon/globalPlugins/clipboardEnhancement/calendar.py index 5e1e461..abd6192 100644 --- a/addon/globalPlugins/clipboardEnhancement/calendar.py +++ b/addon/globalPlugins/clipboardEnhancement/calendar.py @@ -1,32 +1,36 @@ import time -from . import sxtwl -from . import constants + +from . import constants, sxtwl + def getTime(): d = time.localtime() return f'{d.tm_hour}点{d.tm_min}分{d.tm_sec}秒' + def getDate(): d = time.localtime() return f'{d.tm_year}年{d.tm_mon}月{d.tm_mday}日,星期{constants.WeekCn[d.tm_wday]}, 第{d.tm_yday}天' + def get_jieqi_time(day): # 当日是否有节气 if day.hasJieQi(): - #获取节气的儒略日数 + # 获取节气的儒略日数 jd = day.getJieQiJD() # 将儒略日数转换成年月日时秒 - t = sxtwl.JD2DD(jd ) + t = sxtwl.JD2DD(jd) # 注意,t.s是小数,需要四舍五入 - tt = "时刻:%d:%d:%d"%(t.h, t.m, round(t.s)) + tt = "时刻:%d:%d:%d" % (t.h, t.m, round(t.s)) return f'今日{constants.jqmc[day.getJieQi()]}, {tt}' else: - for i in range(2,32): + for i in range(2, 32): day = day.before(1) if day.hasJieQi(): jq = constants.jqmc[day.getJieQi()] return f'{jq}第{i}天' + def get_lunar_month_days(day): # 一个农历月的天数 year = day.getLunarYear(False) @@ -39,29 +43,31 @@ def get_lunar_month_days(day): def get_lunar_date(day): # 以立春为界的农历 - s = "%s%s月%s" % (#day.getLunarYear(False), - '闰' if day.isLunarLeap() else '', constants.Ymc[day.getLunarMonth()], constants.rmc[day.getLunarDay()-1]) -# s = s + '\n今日 %s %s' % (constants.jqmc[day.getJieQi()], tt) + s = "%s%s月%s" % ( # day.getLunarYear(False), + '闰' if day.isLunarLeap() else '', constants.Ymc[day.getLunarMonth()], constants.rmc[day.getLunarDay() - 1]) + # s = s + '\n今日 %s %s' % (constants.jqmc[day.getJieQi()], tt) return s + def get_gz(day, tm): # 以立春为界的天干地支 (注,如果没有传参,或者传false,是以立春为界的。刚好和getLunarYear相反) yTG = day.getYearGZ() # 年干支 ygz = constants.Gan[yTG.tg] + constants.Zhi[yTG.dz] shx = "生肖:" + constants.ShX[yTG.dz] - #月干支 + # 月干支 mTG = day.getMonthGZ() mgz = constants.Gan[mTG.tg] + constants.Zhi[mTG.dz] - #日干支 - dTG = day.getDayGZ() + # 日干支 + dTG = day.getDayGZ() dgz = constants.Gan[dTG.tg] + constants.Zhi[dTG.dz] - #时干支,传24小时制的时间,分早晚子时 + # 时干支,传24小时制的时间,分早晚子时 hour = tm.tm_hour sTG = day.getHourGZ(hour) sgz = constants.Gan[sTG.tg] + constants.Zhi[sTG.dz] return f'{ygz}年,{mgz}月,{dgz}日,{sgz}时。\n{shx}' + def get_jieqi_before(day): while True: day = day.before(1) @@ -71,6 +77,7 @@ def get_jieqi_before(day): jqDay = '农历' + get_lunar_date(day) return f'{day.getSolarMonth()}月{day.getSolarDay()}日 {jq}, {jqDay}' + def get_jieqi_after(day): while True: day = day.after(1) @@ -79,6 +86,7 @@ def get_jieqi_after(day): jqDay = '农历' + get_lunar_date(day) return f'{day.getSolarMonth()}月{day.getSolarDay()}日 {jq}, {jqDay}' + ''' 1.获取某日的前几天或者后几天的信息 (可以用到很多场景中) # 获取某天的后面几天 @@ -128,7 +136,7 @@ def get_jieqi_after(day): break 1.四柱反查 (好像还有bug,待修复) # 四柱反查工具方法 -# 实际项目中不要这样子搞哈,因为汉字utf-8,GBK2312不同的编码。建议还是直接使用天干地支的数字索引 +# 实际项目中不要这样子搞哈,因为汉字utf-8,GBK2312不同的编码。建议还是直接使用天干地支的数字索引 def getGZ(gzStr): tg = -1 dz = -1 @@ -139,7 +147,7 @@ def getGZ(gzStr): for i, v in enumerate(constants.Zhi): if gzStr[1] == v: dz = i - break + break return sxtwl.GZ(tg, dz) # 四注反查 分别传的是年天干,月天干,日天干,时天干, 开始查询年,结束查询年 返回满足条件的儒略日数 jds = sxtwl.siZhu2Year(getGZ('辛丑'), getGZ('己亥'), getGZ('丙寅'), getGZ('癸巳'), 2003, 2029); @@ -148,27 +156,35 @@ def getGZ(gzStr): print("符合条件的时间:%d-%d-%d %d:%d:%d"%(t.Y, t.M, t.D, t.h, t.m, round(t.s))) ''' + def makeDay(): - tm = time.localtime() #返回的是命名元组 + tm = time.localtime() # 返回的是命名元组 # 从公历年月日获取一天的信息 day = sxtwl.fromSolar(tm.tm_year, tm.tm_mon, tm.tm_mday) # 从农历年月日获取一天的信息 # day = sxtwl.fromLunar(2020, 12, 1) return day, tm + def getLunarDate(): day, tm = makeDay() - return '。\n'.join((get_lunar_date(day), + return '。\n'.join(( + get_lunar_date(day), get_lunar_month_days(day), - get_gz(day, tm))) + get_gz(day, tm) + )) + def getJieQi(): - day, tm = makeDay() - return '。\n'.join((get_jieqi_time(day), + day, _ = makeDay() + return '。\n'.join([ + get_jieqi_time(day), get_jieqi_before(day), - get_jieqi_after(day))) + get_jieqi_after(day) + ]) + def get_constellation(): # 星座(有bug?待修复) - day,tm = makeDay() - return constants.XiZ[day.getConstellation()]+'座' + day, _ = makeDay() + return constants.XiZ[day.getConstellation()] + '座' diff --git a/addon/globalPlugins/clipboardEnhancement/sxtwl.py b/addon/globalPlugins/clipboardEnhancement/sxtwl.py index b037f1c..f25ab48 100644 --- a/addon/globalPlugins/clipboardEnhancement/sxtwl.py +++ b/addon/globalPlugins/clipboardEnhancement/sxtwl.py @@ -232,6 +232,9 @@ def capacity(self): class Time(object): thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") __repr__ = _swig_repr + + def __init__(self, *args): + _sxtwl.Time_swiginit(self, _sxtwl.new_Time(*args)) Y = property(_sxtwl.Time_Y_get, _sxtwl.Time_Y_set) M = property(_sxtwl.Time_M_get, _sxtwl.Time_M_set) D = property(_sxtwl.Time_D_get, _sxtwl.Time_D_set) @@ -239,8 +242,41 @@ class Time(object): m = property(_sxtwl.Time_m_get, _sxtwl.Time_m_set) s = property(_sxtwl.Time_s_get, _sxtwl.Time_s_set) - def __init__(self): - _sxtwl.Time_swiginit(self, _sxtwl.new_Time()) + def getYear(self): + return _sxtwl.Time_getYear(self) + + def setYear(self, year): + return _sxtwl.Time_setYear(self, year) + + def setMonth(self, month): + return _sxtwl.Time_setMonth(self, month) + + def getMonth(self): + return _sxtwl.Time_getMonth(self) + + def getDay(self): + return _sxtwl.Time_getDay(self) + + def setDay(self, day): + return _sxtwl.Time_setDay(self, day) + + def getHour(self): + return _sxtwl.Time_getHour(self) + + def setHour(self, hour): + return _sxtwl.Time_setHour(self, hour) + + def getMin(self): + return _sxtwl.Time_getMin(self) + + def setMour(self, min): + return _sxtwl.Time_setMour(self, min) + + def getSec(self): + return _sxtwl.Time_getSec(self) + + def setSec(self, sec): + return _sxtwl.Time_setSec(self, sec) __swig_destroy__ = _sxtwl.delete_Time # Register Time in _sxtwl: @@ -298,8 +334,8 @@ def getMonthGZ(self): def getDayGZ(self): return _sxtwl.Day_getDayGZ(self) - def getHourGZ(self, hour): - return _sxtwl.Day_getHourGZ(self, hour) + def getHourGZ(self, hour, isZaoWanZiShi=True): + return _sxtwl.Day_getHourGZ(self, hour, isZaoWanZiShi) def isLunarLeap(self): return _sxtwl.Day_isLunarLeap(self) @@ -351,8 +387,8 @@ def fromLunar(year, month, day, isRun=False): def siZhu2Year(year, yue, ri, shi, fromYear, toYear): return _sxtwl.siZhu2Year(year, yue, ri, shi, fromYear, toYear) -def getShiGz(dayTg, hour): - return _sxtwl.getShiGz(dayTg, hour) +def getShiGz(dayTg, hour, isZaoWanZiShi=True): + return _sxtwl.getShiGz(dayTg, hour, isZaoWanZiShi) def getRunMonth(By): return _sxtwl.getRunMonth(By)