123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- <?php
- namespace common\util;
- class Holiday
- {
- public static $holiday = [
- 20010101,//2001
- 20010124, 20010125, 20010126, 20010127, 20010128, 20010129, 20010130,
- 20010501, 20010502, 20010503, 20010504, 20010505, 20010506, 20010507,
- 20011001, 20011002, 20011003, 20011004, 20011005, 20011006, 20011007,
- 20020101, 20020102, 20020103,//2002
- 20020212, 20020213, 20020214, 20020215, 20020216, 20020217, 20020218,
- 20020501, 20020502, 20020503, 20020504, 20020505, 20020506, 20020507,
- 20021001, 20021002, 20021003, 20021004, 20021005, 20021006, 20021007,
- 20030101,//2003
- 20030201, 20030202, 20030203, 20030204, 20030205, 20030206, 20030207,
- 20030501, 20030502, 20030503, 20030504, 20030505, 20030506, 20030507,
- 20031001, 20031002, 20031003, 20031004, 20031005, 20031006, 20031007,
- 20040101,//2004
- 20040122, 20040123, 20040124, 20040125, 20040126, 20040127, 20040128,
- 20040501, 20040502, 20040503, 20040504, 20040505, 20040506, 20040507,
- 20041001, 20041002, 20041003, 20041004, 20041005, 20041006, 20041007,
- 20050101, 20050102, 20050103,//2005
- 20050209, 20050210, 20050211, 20050212, 20050213, 20050214, 20050215,
- 20050501, 20050502, 20050503, 20050504, 20050505, 20050506, 20050507,
- 20051001, 20051002, 20051003, 20051004, 20051005, 20051006, 20051007,
- 20060101, 20060102, 20060103,//2006
- 20060129, 20060130, 20060131, 20060201, 20060202, 20060203, 20060204,
- 20060501, 20060502, 20060503, 20060504, 20060505, 20060506, 20060507,
- 20061001, 20061002, 20061003, 20061004, 20061005, 20061006, 20061007,
- 20070101, 20070102, 20070103,//2007
- 20070218, 20070219, 20070220, 20070221, 20070222, 20070223, 20070224,
- 20070501, 20070502, 20070503, 20070504, 20070505, 20070506, 20070507,
- 20071001, 20071002, 20071003, 20071004, 20071005, 20071006, 20071007,
- 20071230, 20071231, 20080101,//2008
- 20080206, 20080207, 20080208, 20080209, 20080210, 20080211, 20080212,
- 20080404, 20080405, 20080406,
- 20080501, 20080502, 20080503,
- 20080607, 20080608, 20080609,
- 20080913, 20080914, 20080915,
- 20080929, 20080930, 20081001, 20081002, 20081003, 20081004, 20081005,
- 20090101, 20090102, 20090103,//2009
- 20090125, 20090126, 20090127, 20090128, 20090129, 20090130, 20090131,
- 20090404, 20090405, 20090406,
- 20090501, 20090502, 20090503,
- 20090528, 20090529, 20090530,
- 20091001, 20091002, 20091003, 20091004, 20091005, 20091006, 20091007, 20091008,
- 20100101, 20100102, 20100103,//2010
- 20100213, 20100214, 20100215, 20100216, 20100217, 20100218, 20100219,
- 20100403, 20100404, 20100405,
- 20100501, 20100502, 20100503,
- 20100614, 20100615, 20100616,
- 20100922, 20100923, 20100924,
- 20101001, 20101002, 20101003, 20101004, 20101005, 20101006, 20101007,
- 20110101, 20110102, 20110103,//2011
- 20110202, 20110203, 20110204, 20110205, 20110206, 20110207, 20110208,
- 20110403, 20110404, 20110405,
- 20110430, 20110501, 20110502,
- 20110604, 20110605, 20110606,
- 20110910, 20110911, 20110912,
- 20111001, 20111002, 20111003, 20111004, 20111005, 20111006, 20111007,
- 20120101, 20120102, 20120103,//2012
- 20120122, 20120123, 20120124, 20120125, 20120126, 20120127, 20120128,
- 20120402, 20120403, 20120404,
- 20120429, 20120430, 20120501,
- 20120622, 20120623, 20120624,
- 20120930, 20121001, 20121002, 20121003, 20121004, 20121005, 20121006, 20121007,
- 20130101, 20130102, 20130103,//2013
- 20130209, 20130210, 20130211, 20130212, 20130213, 20130214, 20130215,
- 20130404, 20130405, 20130406,
- 20130429, 20130430, 20130501,
- 20130610, 20130611, 20130612,
- 20130919, 20130920, 20130921,
- 20131001, 20131002, 20131003, 20131004, 20131005, 20131006, 20131007,
- 20140101,//2014
- 20140131, 20140201, 20140202, 20140203, 20140204, 20140205, 20140206,
- 20140405, 20140406, 20140407,
- 20140501, 20140502, 20140503,
- 20140531, 20140601, 20140602,
- 20140906, 20140907, 20140908,
- 20141001, 20141002, 20141003, 20141004, 20141005, 20141006, 20141007,
- 20150101, 20150102, 20150103,//2015
- 20150218, 20150219, 20150220, 20150221, 20150222, 20150223, 20150224,
- 20150404, 20150405, 20150406,
- 20150501, 20150502, 20150503,
- 20150620, 20150621, 20150622,
- 20150903, 20150904, 20150905,//反法西斯70周年
- 20150926, 20150927,
- 20151001, 20151002, 20151003, 20151004, 20151005, 20151006, 20151007,
- 20160101, 20160102, 20160103,//2016
- 20160207, 20160208, 20160209, 20160210, 20160211, 20160212, 20160213,
- 20160402, 20160403, 20160404,
- 20160430, 20160501, 20160502,
- 20160609, 20160610, 20160611,
- 20160915, 20160916, 20160917,
- 20161001, 20161002, 20161003, 20161004, 20161005, 20161006, 20161007,
- 20161231, 20170101, 20170102,//2017
- 20170127, 20170128, 20170129, 20170130, 20170131, 20170201, 20170202,
- 20170402, 20170403, 20170404,
- 20170429, 20170430, 20170501,
- 20170528, 20170529, 20170530,
- 20171001, 20171002, 20171003, 20171004, 20171005, 20171006, 20171007, 20171008,
- 20121230, 20171231, 20180101,//2018
- 20180215, 20180216, 20180217, 20180218, 20180219, 20180220, 20180221,
- 20180405, 20180406, 20180407,
- 20180429, 20180430, 20180501,
- 20180616, 20180617, 20180618,
- 20180922, 20180923, 20180924,
- 20181001, 20181002, 20181003, 20181004, 20181005, 20181006, 20181007,
- 20181230, 20181231, 20190101,//2019
- 20190204, 20190205, 20190206, 20190207, 20190208, 20190209, 20190210,
- 20190405, 20190406, 20190407,
- 20190501, 20190502, 20190503, 20190504,
- 20190607, 20190608, 20190609,
- 20190913, 20190914, 20190915,
- 20191001, 20191002, 20191003, 20191004, 20191005, 20191006, 20191007,
- 20200101,//2020
- 20200124, 20200125, 20200126, 20200127, 20200128, 20200129, 20200130, 20200131, 20200201, 20200202,
- 20200404, 20200405, 20200406,
- 20200501, 20200502, 20200503, 20200504, 20200505,
- 20200625, 20200626, 20200627,
- 20201001, 20201002, 20201003, 20201004, 20201005, 20201006, 20201007, 20201008,
- 20210101, 20210102, 20210103,//2021
- 20210211, 20210212, 20210213, 20210214, 20210215, 20210216, 20210217,
- 20210403, 20210404, 20210405,
- 20210501, 20210502, 20210503, 20210504, 20210505,
- 20210612, 20210613, 20210614,
- 20210919, 20210920, 20210921,
- 20211001, 20211002, 20211003, 20211004, 20211005, 20211006, 20211007,
- 20220101, 20220102, 20220103,//2022
- 20220131, 20220201, 20220202, 20220203, 20220204, 20220205, 20220206,
- 20220403, 20220404, 20220405,
- 20220430, 20220501, 20220502, 20220503, 20220504,
- 20220603, 20220604, 20220605,
- 20220910, 20220911, 20220912,
- 20221001, 20221002, 20221003, 20221004, 20221005, 20221006, 20221007,
- 20221231, 20230101, 20230102,//2023
- 20230121, 20230122, 20230123, 20230124, 20230125, 20230126, 20230127,
- 20230405,
- 20230429, 20230430, 20230501, 20230502, 20230503,
- 20230622, 20230623, 20230624,
- 20230929, 20230930, 20231001, 20231002, 20231003, 20231004, 20231005, 20231006,
- 20231230, 20231231, 20240101,//2024
- 20240210, 20240211, 20240212, 20240213, 20240214, 20240215, 20240216, 20240217,
- 20240404, 20240405, 20240406,
- 20240501, 20240502, 20240503, 20240504, 20240505,
- 20240608, 20240609, 20240610,
- 20240915, 20240916, 20240917,
- 20211001, 20211002, 20211003, 20211004, 20211005, 20211006, 20211007,
- ];
- public static $weekday = [
- 20010120, 20010121,//2001
- 20010428, 20010429,
- 20010929, 20010930,
- 20021229, 20021230,//2002
- 20020209, 20020210,
- 20020427, 20020428,
- 20020928, 20020929,
- 20030208,//2003
- 20030209,
- 20030426, 20030427,
- 20030927, 20030928,
- 20040117,//2004
- 20040118,
- 20040508,
- 20040509,
- 20041009,
- 20041010,
- 20050205,//2005
- 20050206,
- 20050430,
- 20050508,
- 20051008,
- 20051009,
- 20051231,
- 20060128,//2006
- 20060205,
- 20060429,
- 20060430,
- 20060930,
- 20061008,
- 20061230,
- 20061231,
- 20070217,//2007
- 20070225,
- 20070428,
- 20070429,
- 20070929,
- 20070930,
- 20071229,
- 20080202,//2008
- 20080203,
- 20080504,
- 20080927,
- 20080928,
- 20090104,//2009
- 20090124,
- 20090201,
- 20090531,
- 20090927,
- 20091010,
- 20100612,//2010
- 20100613,
- 20100919,
- 20100925,
- 20100926,
- 20101009,
- 20110130,//2011
- 20110212,
- 20110402,
- 20111008,
- 20111009,
- 20111231,
- 20120121,//2012
- 20120129,
- 20120331,
- 20120401,
- 20120428,
- 20120929,
- 20130105,//2013
- 20130106,
- 20130216,
- 20130217,
- 20130407,
- 20130427,
- 20130428,
- 20130608,
- 20130609,
- 20130922,
- 20130929,
- 20131012,
- 20140126,//2014
- 20140208,
- 20140504,
- 20140928,
- 20141011,
- 20150104,//2015
- 20150215,
- 20150228,
- 20150906,
- 20151010,
- 20160206,//2016
- 20160214,
- 20160612,
- 20160918,
- 20161008,
- 20161009,
- 20170122,//2017
- 20170204,
- 20170401,
- 20170527,
- 20170930,
- 20180211,//2018
- 20180224,
- 20180408,
- 20180428,
- 20180929,
- 20180930,
- 20181229,
- 20190202,//2019
- 20190203,
- 20190428,
- 20190505,
- 20190929,
- 20191012,
- 20200119,//2020
- 20200426,
- 20200509,
- 20200628,
- 20200927,
- 20201010,
- 20210207,//2021
- 20210220,
- 20210425,
- 20210508,
- 20210918,
- 20210926,
- 20211009,
- 20220129,//2022
- 20220130,
- 20220402,
- 20220424,
- 20220507,
- 20221008,
- 20221009,
- 20230128,//2023
- 20230129,
- 20230423,
- 20230506,
- 20230625,
- 20231007,
- 20231008,
- 20240204,//2024
- 20240218,
- 20240407,
- 20240428,
- 20240511,
- 20240914,
- 20240929,
- 20241012,
- ];
- public static function getDayTypeAndTimeType($time)
- {
- //日期特征
- $dayType = self::dayTypeCheck($time);
- //时间特征
- $timeType = self::timeTypeCheck($dayType, $time);
- //从dictionary表获得数据
- $dayTypeArray = [
- 154, 155, 156
- ];
- $timeTypeArray = [
- 158, 159, 160, 161, 162, 163
- ];
- //返回数据
- return [$dayTypeArray[$dayType], $timeTypeArray[$timeType]];
- }
- protected static function dayTypeCheck($time)
- {
- $type = 0;//工作日
- $date = date("Ymd", $time);
- if (in_array($date, self::$holiday)) {
- //判断是否是节假日
- $type = 2;
- } else if (in_array($date, self::$weekday)) {
- //判断是否是节假日补班
- $type = 0;
- } else if (date('N', $time) >= 6) {
- //判断是否是周末
- $type = 1;
- }
- return $type;
- }
- protected static function timeTypeCheck($dayType, $time)
- {
- $timeNew = intval(date("His", $time));
- if ($dayType == 0) {
- //工作日
- if ($timeNew < 70000) {
- $type = 0;
- } else if ($timeNew >= 70000 && $timeNew <= 90000) {
- $type = 1;
- } else if ($timeNew < 170000) {
- $type = 2;
- } else if ($timeNew >= 170000 && $timeNew <= 190000) {
- $type = 3;
- } else {
- $type = 4;
- }
- } else {
- //非工作日
- if ($timeNew < 70000) {
- $type = 0;
- } else if ($timeNew >= 80000 && $timeNew <= 200000) {
- $type = 5;
- } else {
- $type = 4;
- }
- }
- return $type;
- }
- }
|