Holiday.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <?php
  2. namespace common\util;
  3. class Holiday
  4. {
  5. public static $holiday = [
  6. 20010101,//2001
  7. 20010124, 20010125, 20010126, 20010127, 20010128, 20010129, 20010130,
  8. 20010501, 20010502, 20010503, 20010504, 20010505, 20010506, 20010507,
  9. 20011001, 20011002, 20011003, 20011004, 20011005, 20011006, 20011007,
  10. 20020101, 20020102, 20020103,//2002
  11. 20020212, 20020213, 20020214, 20020215, 20020216, 20020217, 20020218,
  12. 20020501, 20020502, 20020503, 20020504, 20020505, 20020506, 20020507,
  13. 20021001, 20021002, 20021003, 20021004, 20021005, 20021006, 20021007,
  14. 20030101,//2003
  15. 20030201, 20030202, 20030203, 20030204, 20030205, 20030206, 20030207,
  16. 20030501, 20030502, 20030503, 20030504, 20030505, 20030506, 20030507,
  17. 20031001, 20031002, 20031003, 20031004, 20031005, 20031006, 20031007,
  18. 20040101,//2004
  19. 20040122, 20040123, 20040124, 20040125, 20040126, 20040127, 20040128,
  20. 20040501, 20040502, 20040503, 20040504, 20040505, 20040506, 20040507,
  21. 20041001, 20041002, 20041003, 20041004, 20041005, 20041006, 20041007,
  22. 20050101, 20050102, 20050103,//2005
  23. 20050209, 20050210, 20050211, 20050212, 20050213, 20050214, 20050215,
  24. 20050501, 20050502, 20050503, 20050504, 20050505, 20050506, 20050507,
  25. 20051001, 20051002, 20051003, 20051004, 20051005, 20051006, 20051007,
  26. 20060101, 20060102, 20060103,//2006
  27. 20060129, 20060130, 20060131, 20060201, 20060202, 20060203, 20060204,
  28. 20060501, 20060502, 20060503, 20060504, 20060505, 20060506, 20060507,
  29. 20061001, 20061002, 20061003, 20061004, 20061005, 20061006, 20061007,
  30. 20070101, 20070102, 20070103,//2007
  31. 20070218, 20070219, 20070220, 20070221, 20070222, 20070223, 20070224,
  32. 20070501, 20070502, 20070503, 20070504, 20070505, 20070506, 20070507,
  33. 20071001, 20071002, 20071003, 20071004, 20071005, 20071006, 20071007,
  34. 20071230, 20071231, 20080101,//2008
  35. 20080206, 20080207, 20080208, 20080209, 20080210, 20080211, 20080212,
  36. 20080404, 20080405, 20080406,
  37. 20080501, 20080502, 20080503,
  38. 20080607, 20080608, 20080609,
  39. 20080913, 20080914, 20080915,
  40. 20080929, 20080930, 20081001, 20081002, 20081003, 20081004, 20081005,
  41. 20090101, 20090102, 20090103,//2009
  42. 20090125, 20090126, 20090127, 20090128, 20090129, 20090130, 20090131,
  43. 20090404, 20090405, 20090406,
  44. 20090501, 20090502, 20090503,
  45. 20090528, 20090529, 20090530,
  46. 20091001, 20091002, 20091003, 20091004, 20091005, 20091006, 20091007, 20091008,
  47. 20100101, 20100102, 20100103,//2010
  48. 20100213, 20100214, 20100215, 20100216, 20100217, 20100218, 20100219,
  49. 20100403, 20100404, 20100405,
  50. 20100501, 20100502, 20100503,
  51. 20100614, 20100615, 20100616,
  52. 20100922, 20100923, 20100924,
  53. 20101001, 20101002, 20101003, 20101004, 20101005, 20101006, 20101007,
  54. 20110101, 20110102, 20110103,//2011
  55. 20110202, 20110203, 20110204, 20110205, 20110206, 20110207, 20110208,
  56. 20110403, 20110404, 20110405,
  57. 20110430, 20110501, 20110502,
  58. 20110604, 20110605, 20110606,
  59. 20110910, 20110911, 20110912,
  60. 20111001, 20111002, 20111003, 20111004, 20111005, 20111006, 20111007,
  61. 20120101, 20120102, 20120103,//2012
  62. 20120122, 20120123, 20120124, 20120125, 20120126, 20120127, 20120128,
  63. 20120402, 20120403, 20120404,
  64. 20120429, 20120430, 20120501,
  65. 20120622, 20120623, 20120624,
  66. 20120930, 20121001, 20121002, 20121003, 20121004, 20121005, 20121006, 20121007,
  67. 20130101, 20130102, 20130103,//2013
  68. 20130209, 20130210, 20130211, 20130212, 20130213, 20130214, 20130215,
  69. 20130404, 20130405, 20130406,
  70. 20130429, 20130430, 20130501,
  71. 20130610, 20130611, 20130612,
  72. 20130919, 20130920, 20130921,
  73. 20131001, 20131002, 20131003, 20131004, 20131005, 20131006, 20131007,
  74. 20140101,//2014
  75. 20140131, 20140201, 20140202, 20140203, 20140204, 20140205, 20140206,
  76. 20140405, 20140406, 20140407,
  77. 20140501, 20140502, 20140503,
  78. 20140531, 20140601, 20140602,
  79. 20140906, 20140907, 20140908,
  80. 20141001, 20141002, 20141003, 20141004, 20141005, 20141006, 20141007,
  81. 20150101, 20150102, 20150103,//2015
  82. 20150218, 20150219, 20150220, 20150221, 20150222, 20150223, 20150224,
  83. 20150404, 20150405, 20150406,
  84. 20150501, 20150502, 20150503,
  85. 20150620, 20150621, 20150622,
  86. 20150903, 20150904, 20150905,//反法西斯70周年
  87. 20150926, 20150927,
  88. 20151001, 20151002, 20151003, 20151004, 20151005, 20151006, 20151007,
  89. 20160101, 20160102, 20160103,//2016
  90. 20160207, 20160208, 20160209, 20160210, 20160211, 20160212, 20160213,
  91. 20160402, 20160403, 20160404,
  92. 20160430, 20160501, 20160502,
  93. 20160609, 20160610, 20160611,
  94. 20160915, 20160916, 20160917,
  95. 20161001, 20161002, 20161003, 20161004, 20161005, 20161006, 20161007,
  96. 20161231, 20170101, 20170102,//2017
  97. 20170127, 20170128, 20170129, 20170130, 20170131, 20170201, 20170202,
  98. 20170402, 20170403, 20170404,
  99. 20170429, 20170430, 20170501,
  100. 20170528, 20170529, 20170530,
  101. 20171001, 20171002, 20171003, 20171004, 20171005, 20171006, 20171007, 20171008,
  102. 20121230, 20171231, 20180101,//2018
  103. 20180215, 20180216, 20180217, 20180218, 20180219, 20180220, 20180221,
  104. 20180405, 20180406, 20180407,
  105. 20180429, 20180430, 20180501,
  106. 20180616, 20180617, 20180618,
  107. 20180922, 20180923, 20180924,
  108. 20181001, 20181002, 20181003, 20181004, 20181005, 20181006, 20181007,
  109. 20181230, 20181231, 20190101,//2019
  110. 20190204, 20190205, 20190206, 20190207, 20190208, 20190209, 20190210,
  111. 20190405, 20190406, 20190407,
  112. 20190501, 20190502, 20190503, 20190504,
  113. 20190607, 20190608, 20190609,
  114. 20190913, 20190914, 20190915,
  115. 20191001, 20191002, 20191003, 20191004, 20191005, 20191006, 20191007,
  116. 20200101,//2020
  117. 20200124, 20200125, 20200126, 20200127, 20200128, 20200129, 20200130, 20200131, 20200201, 20200202,
  118. 20200404, 20200405, 20200406,
  119. 20200501, 20200502, 20200503, 20200504, 20200505,
  120. 20200625, 20200626, 20200627,
  121. 20201001, 20201002, 20201003, 20201004, 20201005, 20201006, 20201007, 20201008,
  122. 20210101, 20210102, 20210103,//2021
  123. 20210211, 20210212, 20210213, 20210214, 20210215, 20210216, 20210217,
  124. 20210403, 20210404, 20210405,
  125. 20210501, 20210502, 20210503, 20210504, 20210505,
  126. 20210612, 20210613, 20210614,
  127. 20210919, 20210920, 20210921,
  128. 20211001, 20211002, 20211003, 20211004, 20211005, 20211006, 20211007,
  129. 20220101, 20220102, 20220103,//2022
  130. 20220131, 20220201, 20220202, 20220203, 20220204, 20220205, 20220206,
  131. 20220403, 20220404, 20220405,
  132. 20220430, 20220501, 20220502, 20220503, 20220504,
  133. 20220603, 20220604, 20220605,
  134. 20220910, 20220911, 20220912,
  135. 20221001, 20221002, 20221003, 20221004, 20221005, 20221006, 20221007,
  136. 20221231, 20230101, 20230102,//2023
  137. 20230121, 20230122, 20230123, 20230124, 20230125, 20230126, 20230127,
  138. 20230405,
  139. 20230429, 20230430, 20230501, 20230502, 20230503,
  140. 20230622, 20230623, 20230624,
  141. 20230929, 20230930, 20231001, 20231002, 20231003, 20231004, 20231005, 20231006,
  142. 20231230, 20231231, 20240101,//2024
  143. 20240210, 20240211, 20240212, 20240213, 20240214, 20240215, 20240216, 20240217,
  144. 20240404, 20240405, 20240406,
  145. 20240501, 20240502, 20240503, 20240504, 20240505,
  146. 20240608, 20240609, 20240610,
  147. 20240915, 20240916, 20240917,
  148. 20211001, 20211002, 20211003, 20211004, 20211005, 20211006, 20211007,
  149. ];
  150. public static $weekday = [
  151. 20010120, 20010121,//2001
  152. 20010428, 20010429,
  153. 20010929, 20010930,
  154. 20021229, 20021230,//2002
  155. 20020209, 20020210,
  156. 20020427, 20020428,
  157. 20020928, 20020929,
  158. 20030208,//2003
  159. 20030209,
  160. 20030426, 20030427,
  161. 20030927, 20030928,
  162. 20040117,//2004
  163. 20040118,
  164. 20040508,
  165. 20040509,
  166. 20041009,
  167. 20041010,
  168. 20050205,//2005
  169. 20050206,
  170. 20050430,
  171. 20050508,
  172. 20051008,
  173. 20051009,
  174. 20051231,
  175. 20060128,//2006
  176. 20060205,
  177. 20060429,
  178. 20060430,
  179. 20060930,
  180. 20061008,
  181. 20061230,
  182. 20061231,
  183. 20070217,//2007
  184. 20070225,
  185. 20070428,
  186. 20070429,
  187. 20070929,
  188. 20070930,
  189. 20071229,
  190. 20080202,//2008
  191. 20080203,
  192. 20080504,
  193. 20080927,
  194. 20080928,
  195. 20090104,//2009
  196. 20090124,
  197. 20090201,
  198. 20090531,
  199. 20090927,
  200. 20091010,
  201. 20100612,//2010
  202. 20100613,
  203. 20100919,
  204. 20100925,
  205. 20100926,
  206. 20101009,
  207. 20110130,//2011
  208. 20110212,
  209. 20110402,
  210. 20111008,
  211. 20111009,
  212. 20111231,
  213. 20120121,//2012
  214. 20120129,
  215. 20120331,
  216. 20120401,
  217. 20120428,
  218. 20120929,
  219. 20130105,//2013
  220. 20130106,
  221. 20130216,
  222. 20130217,
  223. 20130407,
  224. 20130427,
  225. 20130428,
  226. 20130608,
  227. 20130609,
  228. 20130922,
  229. 20130929,
  230. 20131012,
  231. 20140126,//2014
  232. 20140208,
  233. 20140504,
  234. 20140928,
  235. 20141011,
  236. 20150104,//2015
  237. 20150215,
  238. 20150228,
  239. 20150906,
  240. 20151010,
  241. 20160206,//2016
  242. 20160214,
  243. 20160612,
  244. 20160918,
  245. 20161008,
  246. 20161009,
  247. 20170122,//2017
  248. 20170204,
  249. 20170401,
  250. 20170527,
  251. 20170930,
  252. 20180211,//2018
  253. 20180224,
  254. 20180408,
  255. 20180428,
  256. 20180929,
  257. 20180930,
  258. 20181229,
  259. 20190202,//2019
  260. 20190203,
  261. 20190428,
  262. 20190505,
  263. 20190929,
  264. 20191012,
  265. 20200119,//2020
  266. 20200426,
  267. 20200509,
  268. 20200628,
  269. 20200927,
  270. 20201010,
  271. 20210207,//2021
  272. 20210220,
  273. 20210425,
  274. 20210508,
  275. 20210918,
  276. 20210926,
  277. 20211009,
  278. 20220129,//2022
  279. 20220130,
  280. 20220402,
  281. 20220424,
  282. 20220507,
  283. 20221008,
  284. 20221009,
  285. 20230128,//2023
  286. 20230129,
  287. 20230423,
  288. 20230506,
  289. 20230625,
  290. 20231007,
  291. 20231008,
  292. 20240204,//2024
  293. 20240218,
  294. 20240407,
  295. 20240428,
  296. 20240511,
  297. 20240914,
  298. 20240929,
  299. 20241012,
  300. ];
  301. public static function getDayTypeAndTimeType($time)
  302. {
  303. //日期特征
  304. $dayType = self::dayTypeCheck($time);
  305. //时间特征
  306. $timeType = self::timeTypeCheck($dayType, $time);
  307. //从dictionary表获得数据
  308. $dayTypeArray = [
  309. 154, 155, 156
  310. ];
  311. $timeTypeArray = [
  312. 158, 159, 160, 161, 162, 163
  313. ];
  314. //返回数据
  315. return [$dayTypeArray[$dayType], $timeTypeArray[$timeType]];
  316. }
  317. protected static function dayTypeCheck($time)
  318. {
  319. $type = 0;//工作日
  320. $date = date("Ymd", $time);
  321. if (in_array($date, self::$holiday)) {
  322. //判断是否是节假日
  323. $type = 2;
  324. } else if (in_array($date, self::$weekday)) {
  325. //判断是否是节假日补班
  326. $type = 0;
  327. } else if (date('N', $time) >= 6) {
  328. //判断是否是周末
  329. $type = 1;
  330. }
  331. return $type;
  332. }
  333. protected static function timeTypeCheck($dayType, $time)
  334. {
  335. $timeNew = intval(date("His", $time));
  336. if ($dayType == 0) {
  337. //工作日
  338. if ($timeNew < 70000) {
  339. $type = 0;
  340. } else if ($timeNew >= 70000 && $timeNew <= 90000) {
  341. $type = 1;
  342. } else if ($timeNew < 170000) {
  343. $type = 2;
  344. } else if ($timeNew >= 170000 && $timeNew <= 190000) {
  345. $type = 3;
  346. } else {
  347. $type = 4;
  348. }
  349. } else {
  350. //非工作日
  351. if ($timeNew < 70000) {
  352. $type = 0;
  353. } else if ($timeNew >= 80000 && $timeNew <= 200000) {
  354. $type = 5;
  355. } else {
  356. $type = 4;
  357. }
  358. }
  359. return $type;
  360. }
  361. }