网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
{
$yearData =
t
h
i
s
−
>
l
u
n
a
r
I
n
f
o
[
this->lunarInfo[
this−>lunarInfo[year-$this->MIN_YEAR];
$monthArray =
t
h
i
s
−
>
g
e
t
L
u
n
a
r
Y
e
a
r
M
o
n
t
h
s
(
this->getLunarYearMonths(
this−>getLunarYearMonths(year);
l
e
n
=
c
o
u
n
t
(
len = count(
len=count(monthArray);
return (
m
o
n
t
h
A
r
r
a
y
[
monthArray[
monthArray[len-1]==0?
m
o
n
t
h
A
r
r
a
y
[
monthArray[
monthArray[len-2]:
m
o
n
t
h
A
r
r
a
y
[
monthArray[
monthArray[len-1]);
}
function getLunarYearMonths($year)
{
//debugger;
$monthData =
t
h
i
s
−
>
g
e
t
L
u
n
a
r
M
o
n
t
h
s
(
this->getLunarMonths(
this−>getLunarMonths(year);
$res=array();
$temp=0;
$yearData =
t
h
i
s
−
>
l
u
n
a
r
I
n
f
o
[
this->lunarInfo[
this−>lunarInfo[year-$this->MIN_YEAR];
l
e
n
=
(
len = (
len=(yearData[0]==0?12:13);
for(
i
=
0
;
i=0;
i=0;i<
l
e
n
;
len;
len;i )
{
t
e
m
p
=
0
;
f
o
r
(
temp=0; for(
temp=0;for(j=0;
j
<
=
j<=
j<=i;$j )
t
e
m
p
=
temp =
temp=monthData[
j
]
;
a
r
r
a
y
_
p
u
s
h
(
j]; array\_push(
j];array_push(res, $temp);
}
return $res;
}
/\*\*
* 获取闰月
* @param year 阴历年份
*/
function getLeapMonth($year)
{
$yearData =
t
h
i
s
−
>
l
u
n
a
r
I
n
f
o
[
this->lunarInfo[
this−>lunarInfo[year-$this->MIN_YEAR];
return $yearData[0];
}
/\*\*
* 计算阴历日期与正月初一相隔的天数
* @param year
* @param month
* @param date
*/
function getDaysBetweenLunar(
y
e
a
r
,
year,
year,month,$date)
{
$yearMonth =
t
h
i
s
−
>
g
e
t
L
u
n
a
r
M
o
n
t
h
s
(
this->getLunarMonths(
this−>getLunarMonths(year);
r
e
s
=
0
;
f
o
r
(
res=0; for(
res=0;for(i=1;
i
<
i<
i<month;$i )
r
e
s
=
res =
res=yearMonth[$i-1];
r
e
s
=
res =
res=date-1;
return $res;
}
/\*\*
* 计算2个阳历日期之间的天数
* @param year 阳历年
* @param cmonth
* @param cdate
* @param dmonth 阴历正月对应的阳历月份
* @param ddate 阴历初一对应的阳历天数
*/
function getDaysBetweenSolar(
y
e
a
r
,
year,
year,cmonth,
c
d
a
t
e
,
cdate,
cdate,dmonth,$ddate)
{
a
=
m
k
t
i
m
e
(
0
,
0
,
0
,
a = mktime(0,0,0,
a=mktime(0,0,0,cmonth,
c
d
a
t
e
,
cdate,
cdate,year);
b
=
m
k
t
i
m
e
(
0
,
0
,
0
,
b = mktime(0,0,0,
b=mktime(0,0,0,dmonth,
d
d
a
t
e
,
ddate,
ddate,year);
return ceil((
a
−
a-
a−b)/24/3600);
}
/\*\*
* 根据距离正月初一的天数计算阴历日期
* @param year 阳历年
* @param between 天数
*/
function getLunarByBetween(
y
e
a
r
,
year,
year,between)
{
//debugger;
$lunarArray = array();
$yearMonth=array();
$t=0;
$e=0;
$leapMonth=0;
m
=
′
′
;
i
f
(
m=''; if(
m=′′;if(between==0)
{
array_push($lunarArray, $year,‘正月’,‘初一’);
$t = 1;
$e = 1;
}
else
{
$year = $between>0?
y
e
a
r
:
(
year : (
year:(year-1);
$yearMonth =
t
h
i
s
−
>
g
e
t
L
u
n
a
r
Y
e
a
r
M
o
n
t
h
s
(
this->getLunarYearMonths(
this−>getLunarYearMonths(year);
$leapMonth =
t
h
i
s
−
>
g
e
t
L
e
a
p
M
o
n
t
h
(
this->getLeapMonth(
this−>getLeapMonth(year);
$between =
b
e
t
w
e
e
n
>
0
?
between>0?
between>0?between : (
t
h
i
s
−
>
g
e
t
L
u
n
a
r
Y
e
a
r
D
a
y
s
(
this->getLunarYearDays(
this−>getLunarYearDays(year)
b
e
t
w
e
e
n
)
;
f
o
r
(
between); for(
between);for(i=0;
i
<
13
;
i<13;
i<13;i )
{
if(
b
e
t
w
e
e
n
=
=
between==
between==yearMonth[$i])
{
t
=
t=
t=i 2;
KaTeX parse error: Expected 'EOF', got '}' at position 57: … }̲else if(between<
y
e
a
r
M
o
n
t
h
[
yearMonth[
yearMonth[i])
{
t
=
t=
t=i 1;
e
=
e=
e=between-(empty(
y
e
a
r
M
o
n
t
h
[
yearMonth[
yearMonth[i-1])?0:
y
e
a
r
M
o
n
t
h
[
yearMonth[
yearMonth[i-1]) 1;
break;
}
}
m
=
(
m = (
m=(leapMonth!=0&&
t
=
=
t==
t==leapMonth 1)?(‘闰’.
t
h
i
s
−
>
g
e
t
C
a
p
i
t
a
l
N
u
m
(
this->getCapitalNum(
this−>getCapitalNum(t- 1,true)):
t
h
i
s
−
>
g
e
t
C
a
p
i
t
a
l
N
u
m
(
(
this->getCapitalNum((
this−>getCapitalNum((leapMonth!=0&&
l
e
a
p
M
o
n
t
h
1
<
leapMonth 1<
leapMonth1<t?(
t
−
1
)
:
t-1):
t−1):t),true);
array_push(
l
u
n
a
r
A
r
r
a
y
,
lunarArray,
lunarArray,year,
m
,
m,
m,this->getCapitalNum(KaTeX parse error: Expected 'EOF', got '}' at position 24: …); }̲ ar…lunarArray,
t
h
i
s
−
>
g
e
t
L
u
n
a
r
Y
e
a
r
N
a
m
e
(
this->getLunarYearName(
this−>getLunarYearName(year));// 天干地支
array_push(
l
u
n
a
r
A
r
r
a
y
,
lunarArray,
lunarArray,t,
e
)
;
a
r
r
a
y
_
p
u
s
h
(
e); array\_push(
e);array_push(lunarArray,
t
h
i
s
−
>
g
e
t
Y
e
a
r
Z
o
d
i
a
c
(
this->getYearZodiac(
this−>getYearZodiac(year));// 12生肖
array_push(
l
u
n
a
r
A
r
r
a
y
,
lunarArray,
lunarArray,leapMonth);// 闰几月
return $lunarArray;
}
/\*\*
* 获取数字的阴历叫法
* @param num 数字
* @param isMonth 是否是月份的数字
*/
function getCapitalNum(
n
u
m
,
num,
num,isMonth)
{
$isMonth = $isMonth || false;
$dateHash=array(‘0’=>‘’,‘1’=>‘一’,‘2’=>‘二’,‘3’=>‘三’,‘4’=>‘四’,‘5’=>‘五’,‘6’=>‘六’,‘7’=>‘七’,‘8’=>‘八’,‘9’=>‘九’,‘10’=>‘十 ‘);
$monthHash=array(‘0’=>’’,‘1’=>‘正月’,‘2’=>‘二月’,‘3’=>‘三月’,‘4’=>‘四月’,‘5’=>‘五月’,‘6’=>‘六月’,‘7’=>‘七月’,‘8’=>‘八月’,‘9’=>‘九月’,‘10’=>‘十月’,‘11’=>‘冬月’,‘12’=>‘腊月’);
r
e
s
=
′
′
;
i
f
(
res=''; if(
res=′′;if(isMonth) $res =
m
o
n
t
h
H
a
s
h
[
monthHash[
monthHash[num];
else
{
if($num<=10)
r
e
s
=
′
初
′
.
res = '初'.
res=′初′.dateHash[
n
u
m
]
;
e
l
s
e
i
f
(
num]; else if(
num];elseif(num>10&&$num<20)
r
e
s
=
′
十
′
.
res = '十'.
res=′十′.dateHash[
n
u
m
−
10
]
;
e
l
s
e
i
f
(
num-10]; else if(
num−10];elseif(num20)
r
e
s
=
"
二十
"
;
e
l
s
e
i
f
(
res = "二十"; else if(
res="二十";elseif(num>20&&$num<30)
r
e
s
=
"
廿
"
.
res = "廿".
res="廿".dateHash[
n
u
m
−
20
]
;
e
l
s
e
i
f
(
num-20]; else if(
num−20];elseif(num30) $res = “三十”;
}
return $res;
}
/\*
* 节气通用算法
*/
function getJieQi(
y
e
a
r
,
_year,
year,month,$day)
{
y
e
a
r
=
s
u
b
s
t
r
(
year = substr(
year=substr(_year,-2) 0;
$coefficient = array(
array(5.4055,2019,-1),//小寒
array(20.12,2082,1),//大寒
array(3.87),//立春
array(18.74,2026,-1),//雨水
array(5.63),//惊蛰
array(20.646,2084,1),//春分
array(4.81),//清明
array(20.1),//谷雨
array(5.52,1911,1),//立夏
array(21.04,2008,1),//小满
array(5.678,1902,1),//芒种
array(21.37,1928,1),//夏至
array(7.108,2016,1),//小暑
array(22.83,1922,1),//大暑
array(7.5,2002,1),//立秋
array(23.13),//处暑
array(7.646,1927,1),//白露
array(23.042,1942,1),//秋分
array(8.318),//寒露
array(23.438,2089,1),//霜降
array(7.438,2089,1),//立冬
array(22.36,1978,1),//小雪
array(7.18,1954,1),//大雪
array(21.94,2021,-1)//冬至
);
$term_name = array(
“小寒”,“大寒”,“立春”,“雨水”,“惊蛰”,“春分”,“清明”,“谷雨”,
“立夏”,“小满”,“芒种”,“夏至”,“小暑”,“大暑”,“立秋”,“处暑”,
“白露”,“秋分”,“寒露”,“霜降”,“立冬”,“小雪”,“大雪”,“冬至”);
$idx1 = ($month-1)\*2;
$_leap_value = floor(($year-1)/4);
$day1 = floor($year\*0.2422 $coefficient[$idx1][0])-$_leap_value;
if(isset($coefficient[$idx1][1])&&$coefficient[$idx1][1]==$_year) $day1 = $coefficient[$idx1][2];
$day2 = floor($year\*0.2422 $coefficient[$idx1 1][0])-$_leap_value;
if(isset($coefficient[$idx1 1][1])&&$coefficient[$idx1 1][1]==$_year) $day1 = $coefficient[$idx1 1][2];
//echo \_\_FILE\_\_.'->'.\_\_LINE\_\_.' $day1='.$day1,',$day2='.$day2.'<br/>'.chr(10);
$data=array();
if($day<$day1){
$data['name1']=$term_name[$idx1-1];
$data['name2']=$term_name[$idx1-1].'后';
}else if($day==$day1){
$data['name1']=$term_name[$idx1];
$data['name2']=$term_name[$idx1];
}else if($day>$day1 && $day<$day2){
$data['name1']=$term_name[$idx1];
$data['name2']=$term_name[$idx1].'后';
}else if($day==$day2){
$data['name1']=$term_name[$idx1 1];
$data['name2']=$term_name[$idx1 1];
}else if($day>$day2){
$data['name1']=$term_name[$idx1 1];
$data['name2']=$term_name[$idx1 1].'后';
}
return $data;
}
/\*
* 获取节日:特殊的节日只能修改此函数来计算
*/
function getFestival($today,
n
l
i
n
f
o
=
f
a
l
s
e
,
nl_info = false,
nlinfo=false,config = 1)
{
if($config == 1)
{
$arr_lunar=array(‘01-01’=>‘春节’,‘01-15’=>‘元宵节’,‘02-02’=>‘二月二’,‘05-05’=>‘端午节’,‘07-07’=>‘七夕节’,‘08-15’=>‘中秋节’,‘09-09’=>‘重阳节’,‘12-08’=>‘腊八节’,‘12-23’=>‘小年’);
KaTeX parse error: Expected 'EOF', got '}' at position 179: …'); }̲//需要不同节日的,用不同的config,然后配置
a
r
r
_
l
u
n
a
r
和
arr\_lunar和
arr_lunar和arr_solar
$festivals = array();
list($y,$m,$d) = explode('-',$today);
if(!$nl_info) $nl_info = $this->convertSolarToLunar($y,intval($m),intval($d));
if($nl_info[7]>0&&$nl_info[7]<$nl_info[4]) $nl_info[4]-=1;
$md_lunar = substr('0'.$nl_info[4],-2).'-'.substr('0'.$nl_info[5],-2);
$md_solar=substr\_replace($today,'',0,5);
isset($arr_lunar[$md_lunar])?array\_push($festivals, $arr_lunar[$md_lunar]):'';
isset($arr_solar[$md_solar])?array\_push($festivals, $arr_solar[$md_solar]):'';
$glweek = date("w",strtotime($today)); //0-6
if($m==5&&($d>7)&&($d<15)&&($glweek==0))array\_push($festivals, "母亲节");
if($m==6&&($d>14)&&($d<22)&&($glweek==0))array\_push($festivals,"父亲节");
$jieqi = $this->getJieQi($y,$m,$d);
if($jieqi)array\_push($festivals,$jieqi);
return implode('/',$festivals);
}
/\*
* 获取当前时间属于哪个时辰
@param int KaTeX parse error: Undefined control sequence: \* at position 11: time 时间戳 \̲*̲/ function …h){
d
=
d=
d=h;
if($d23 ||
d
=
=
0
)
r
e
t
u
r
n
′
子
时
′
;
e
l
s
e
i
f
(
d==0){ return '子时'; }else if(
d==0)return′子时′;elseif(d1 ||
d
=
=
2
)
r
e
t
u
r
n
′
丑
时
′
;
e
l
s
e
i
f
(
d==2){ return '丑时'; }else if(
d==2)return′丑时′;elseif(d3 ||
d
=
=
4
)
r
e
t
u
r
n
′
寅
时
′
;
e
l
s
e
i
f
(
d==4){ return '寅时'; }else if(
d==4)return′寅时′;elseif(d5 ||
d
=
=
6
)
r
e
t
u
r
n
′
卯
时
′
;
e
l
s
e
i
f
(
d==6){ return '卯时'; }else if(
d==6)return′卯时′;elseif(d7 ||
d
=
=
8
)
r
e
t
u
r
n
′
辰
时
′
;
e
l
s
e
i
f
(
d==8){ return '辰时'; }else if(
d==8)return′辰时′;elseif(d9 ||
d
=
=
10
)
r
e
t
u
r
n
′
巳
时
′
;
e
l
s
e
i
f
(
d==10){ return '巳时'; }else if(
d==10)return′巳时′;elseif(d11 ||
d
=
=
12
)
r
e
t
u
r
n
′
午
时
′
;
e
l
s
e
i
f
(
d==12){ return '午时'; }else if(
d==12)return′午时′;elseif(d13 ||
d
=
=
14
)
r
e
t
u
r
n
′
未
时
′
;
e
l
s
e
i
f
(
d==14){ return '未时'; }else if(
d==14)return′未时′;elseif(d15 ||
d
=
=
16
)
r
e
t
u
r
n
′
申
时
′
;
e
l
s
e
i
f
(
d==16){ return '申时'; }else if(
d==16)return′申时′;elseif(d17 ||
d
=
=
18
)
r
e
t
u
r
n
′
酉
时
′
;
e
l
s
e
i
f
(
d==18){ return '酉时'; }else if(
d==18)return′酉时′;elseif(d19 ||
d
=
=
20
)
r
e
t
u
r
n
′
戌
时
′
;
e
l
s
e
i
f
(
d==20){ return '戌时'; }else if(
d==20)return′戌时′;elseif(d21 || KaTeX parse error: Expected 'EOF', got '}' at position 48: … } }̲ } /\*lunar=new Lunar();//
m
o
n
t
h
=
month=
month=lunar->getJieQi(2017,05,13);//将阳历转换为阴历
echo ‘
’;
print_r($month);*/
![img](https://img-blog.csdnimg.cn/img_convert/4c62eb276ca7b50d9c91d0b21376abab.png)
![img](https://img-blog.csdnimg.cn/img_convert/73e25041e9b5f35eb9f6d589f16901f2.png)
![img](https://img-blog.csdnimg.cn/img_convert/673d49326c38ae8d7557b540208eadb8.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[如果你需要这些资料,可以戳这里获取](https://bbs.csdn.net/topics/618658159)**
9)]
[外链图片转存中...(img-GlTcK41T-1715637404650)]
[外链图片转存中...(img-Du6uMacZ-1715637404650)]
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[如果你需要这些资料,可以戳这里获取](https://bbs.csdn.net/topics/618658159)**