AHKv1获取整年24节气数据

输入公历日期获取后面一年的节气数据


/*
	Author:leeonchiu
	Description:输入公历日期获取后面一年的节气数据
*/

string:=""
for key,value in GetYearJq(A_Now,False)
	string.=value[1] "-" value[2] "`n"
MsgBox,4096,, % string

GetLunarJqData(date){   ;by leeonchiu
	year:=SubStr(date,1,4), month:=SubStr(date,5,2), D:=0.2422, Y:=SubStr(year,3,2), L:=month>2?Floor(SubStr(year,3,2)/4):Floor((SubStr(year,3,2)-1)/4)
	if (Not year~="^(19|20)"||month>12||month<1)
		Return []
	if year Between 1900 And 1999
	{
		Data:=[[[6.11,"小寒",12,"xh"],[20.84,"大寒",12,"dh"]],[[4.6295,"立春",1,"lc"],[19.4599,"雨水",1,"ys"]],[[6.3826,"惊蛰",2,"jz"],[21.4155,"春分",2,"cf"]],[[5.59,"清明",3,"qm"],[20.888,"谷雨",3,"gy"]],[[6.318,"立夏",4,"lx"],[21.86,"小满",4,"xm"]],[[6.5,"芒种",5,"mz"],[22.2,"夏至",5,"xz"]],[[7.928,"小暑",6,"xs"],[23.65,"大暑",6,"ds"]],[[28.35,"立秋",7,"lq"],[23.95,"处暑",7,"cs"]],[[8.44,"白露",8,"bl"],[23.822,"秋分",8,"qf"]],[[9.098,"寒露",9,"hl"],[24.218,"霜降",9,"sj"]],[[8.218,"立冬",10,"ld"],[23.08,"小雪",10,"xx"]],[[7.9,"大雪",11,"dx"],[22.6,"冬至",11,"dz"]]]
		obj:=[[Floor(Y*D+Data[month,1,1])-L,Data[month,1,2],Data[month,1,4]],[Floor(Y*D+Data[month,2,1])-L,Data[month,2,2],Data[month,2,4]]]
	}
	else if year Between 2000 And 2099
	{
		Data:=[[[5.4055,"小寒",12,"xh"],[20.12,"大寒",12,"dh"]],[[3.87,"立春",1,"lc"],[18.73,"雨水",1,"ys"]],[[5.63,"惊蛰",2,"jz"],[20.646,"春分",2,"cf"]],[[4.81,"清明",3,"qm"],[20.1,"谷雨",3,"gy"]],[[5.52,"立夏",4,"lx"],[21.04,"小满",4,"xm"]],[[5.678,"芒种",5,"mz"],[21.37,"夏至",5,"xz"]],[[7.108,"小暑",6,"xs"],[22.83,"大暑",6,"ds"]],[[7.5,"立秋",7,"lq"],[23.13,"处暑",7,"cs"]],[[7.646,"白露",8,"bl"],[23.042,"秋分",8,"qf"]],[[8.318,"寒露",9,"hl"],[23.438,"霜降",9,"sj"]],[[7.438,"立冬",10,"ld"],[22.36,"小雪",10,"xx"]],[[7.18,"大雪",11,"dx"],[21.94,"冬至",11,"dz"]]]
		obj:=[[Floor(Y*D+Data[month,1,1])-L,Data[month,1,2],Data[month,1,4]],[Floor(Y*D+Data[month,2,1])-L,Data[month,2,2],Data[month,2,4]]]
	}
	Plus:={1902:{"mz":6},1911:{"lx":5},1922:{"ds":7},1925:{"xs":7},1927:{"bl":9},1928:{"xz":6},1942:{"qf":9},1954:{"dx":12},1978:{"xx":11},1982:{"xh":1},2000:{"dh":1},2002:{"lq":8}
		,2008:{"xm":5},2016:{"xs":7},2082:{"dh":1},2084:{"cf":3},2089:{"sj":10,"ld":8}}
	Reduce:={2026:{"ys":2},1918:{"dz":12},2021:{"dz":12},2019:{"xh":1}}
	if objCount(Plus[year]){
		for key,value in Plus[year]
		{
			Count:=0
			if (key=obj[1,3]&&year Format("{:02d}",value)=year Format("{:02d}",month)){
				obj[1,1]:=obj[1,1]+1,Count++
			}
			if (key=obj[2,3]&&value=month&&!Count){
				obj[2,1]:=obj[2,1]+1
			}
		}
	}
	if objCount(Reduce[year]){
		for key,value in Reduce[year]
		{
			Count:=0
			if (key=obj[1,3]&&year Format("{:02d}",value)=year Format("{:02d}",month)){
				obj[1,1]:=obj[1,1]-1,Count++
			}
			if (key=obj[2,3]&&value=month&&!Count){
				obj[2,1]:=obj[2,1]-1
			}
		}
	}
	obj[1,1]:= year "-" month "-" Format("{:02d}",obj[1,1]),obj[2,1]:= year "-" month "-" Format("{:02d}",obj[2,1])

	Return obj
}

;t=1时过滤输入日期月份已过期的节气,t=0不过滤
GetYearJq(date,t:=True){   ;by leeonchiu
	year:=SubStr(date,1,4), month:=SubStr(date,5,2), Day:=SubStr(date,7,2),result:=[]
	if (Not year~="^(19|20)"||month>12||month<1)
		Return []
	Loop,12
	{
		if (A_Index=1){
			if objLength(JqData:=GetLunarJqData(date)){
				if (Day&&Day>SubStr(JqData[1,1],-1)&&t&&Day<=SubStr(JqData[1,1],-1))
					result.InsertAt(objLength(result)+1,JqData[2])
				Else if (Day&&Day<=SubStr(JqData[1,1],-1)&&t&&Day<=SubStr(JqData[1,1],-1)||!t)
					result.InsertAt(objLength(result)+1,JqData[1],JqData[2])
			}
		}Else{
			year:=month+1=13?year+1:year,month:=month+1=13?1:month+1
			if objLength(JqData:=GetLunarJqData(year Format("{:02d}",month))){
				result.InsertAt(objLength(result)+1,JqData[1],JqData[2])
			}
		}
	}

	Return result
}

给TA打赏
共{{data.count}}人
人已打赏
AHKV1代码示例近期更新

自由截图示例

2021-12-24 15:06:05

AHKV1近期更新

AHKv1前台活动窗口监控

2021-12-25 10:38:40

2 条回复 A文章作者 M管理员
  1. lfer

    👍

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索