Skip to content

Commit

Permalink
feat: Supplement the holidays for the year 2024
Browse files Browse the repository at this point in the history
补充中国2024年节假日

Log:
  • Loading branch information
myml committed Dec 27, 2023
1 parent f8ed8ab commit 7872dd6
Show file tree
Hide file tree
Showing 5 changed files with 259 additions and 91 deletions.
67 changes: 28 additions & 39 deletions calendar-client/src/dbus/dbushuanglirequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "dbushuanglirequest.h"

#include "commondef.h"

#include <QDebug>

DbusHuangLiRequest::DbusHuangLiRequest(QObject *parent)
: DbusRequestBase("/com/deepin/dataserver/Calendar/HuangLi", "com.deepin.dataserver.Calendar.HuangLi", QDBusConnection::sessionBus(), parent)
: DbusRequestBase("/com/deepin/dataserver/Calendar/HuangLi",
"com.deepin.dataserver.Calendar.HuangLi",
QDBusConnection::sessionBus(),
parent)
{

}

/**
Expand All @@ -18,7 +22,7 @@ DbusHuangLiRequest::DbusHuangLiRequest(QObject *parent)
* @param year
* @param month
*/
bool DbusHuangLiRequest::getFestivalMonth(quint32 year, quint32 month, FestivalInfo& festivalInfo)
bool DbusHuangLiRequest::getFestivalMonth(quint32 year, quint32 month, FestivalInfo &festivalInfo)
{
QDBusPendingReply<QString> reply = call("getFestivalMonth", QVariant(year), QVariant(month));

Expand All @@ -34,41 +38,18 @@ bool DbusHuangLiRequest::getFestivalMonth(quint32 year, quint32 month, FestivalI
if (json_error.error != QJsonParseError::NoError) {
return false;
}
//解析数据
// 解析数据
QJsonArray rootarry = jsonDoc.array();
for (int i = 0; i < rootarry.size(); i++) {
QJsonObject subObj = rootarry.at(i).toObject();
//因为是预先定义好的JSON数据格式,所以这里可以这样读取
if (subObj.contains("id")) {
festivalInfo.ID = subObj.value("id").toString();
}
if (subObj.contains("name")) {
festivalInfo.FestivalName = subObj.value("name").toString();
}
if (subObj.contains("description")) {
festivalInfo.description = subObj.value("description").toString();
}
if (subObj.contains("rest")) {
festivalInfo.Rest = subObj.value("rest").toString();
}
if (subObj.contains("month")) {
festivalInfo.month = subObj.value("month").toInt();
QJsonObject hsubObj = rootarry.at(i).toObject();
HolidayInfo dayinfo;
if (hsubObj.contains("status")) {
dayinfo.status = static_cast<char>(hsubObj.value("status").toInt());
}
if (subObj.contains("list")) {
QJsonArray sublistArray = subObj.value("list").toArray();
for (int j = 0; j < sublistArray.size(); j++) {
QJsonObject hsubObj = sublistArray.at(j).toObject();
HolidayInfo dayinfo;
if (hsubObj.contains("status")) {
dayinfo.status = static_cast<char>(hsubObj.value("status").toInt());
}
if (hsubObj.contains("date")) {
dayinfo.date = QDate::fromString(hsubObj.value("date").toString(), "yyyy-M-d");
}
festivalInfo.listHoliday.append(dayinfo);
}
if (hsubObj.contains("date")) {
dayinfo.date = QDate::fromString(hsubObj.value("date").toString(), "yyyy-MM-dd");
}
festivalInfo.year = static_cast<int>(year);
festivalInfo.listHoliday.append(dayinfo);
}
return true;
}
Expand All @@ -80,9 +61,13 @@ bool DbusHuangLiRequest::getFestivalMonth(quint32 year, quint32 month, FestivalI
* @param month
* @param day
*/
bool DbusHuangLiRequest::getHuangLiDay(quint32 year, quint32 month, quint32 day, CaHuangLiDayInfo &info)
bool DbusHuangLiRequest::getHuangLiDay(quint32 year,
quint32 month,
quint32 day,
CaHuangLiDayInfo &info)
{
QDBusPendingReply<QString> reply = call("getHuangLiDay", QVariant(year), QVariant(month), QVariant(day));
QDBusPendingReply<QString> reply =
call("getHuangLiDay", QVariant(year), QVariant(month), QVariant(day));

if (reply.isError()) {
qCWarning(ClientLogger) << reply.error().message();
Expand All @@ -102,9 +87,13 @@ bool DbusHuangLiRequest::getHuangLiDay(quint32 year, quint32 month, quint32 day,
* @param month
* @param fill
*/
bool DbusHuangLiRequest::getHuangLiMonth(quint32 year, quint32 month, bool fill, CaHuangLiMonthInfo &info)
bool DbusHuangLiRequest::getHuangLiMonth(quint32 year,
quint32 month,
bool fill,
CaHuangLiMonthInfo &info)
{
QDBusPendingReply<QString> reply = call("getHuangLiMonth", QVariant(year), QVariant(month), QVariant(fill));
QDBusPendingReply<QString> reply =
call("getHuangLiMonth", QVariant(year), QVariant(month), QVariant(fill));
if (reply.isError()) {
qCWarning(ClientLogger) << reply.error().message();
return false;
Expand Down Expand Up @@ -140,7 +129,7 @@ void DbusHuangLiRequest::getLunarMonthCalendar(quint32 year, quint32 month, bool
asyncCall("getLunarMonthCalendar", QVariant(year), QVariant(month), QVariant(fill));
}

void DbusHuangLiRequest::slotCallFinished(CDBusPendingCallWatcher* call)
void DbusHuangLiRequest::slotCallFinished(CDBusPendingCallWatcher *call)
{
if (call->isError()) {
qCWarning(ClientLogger) << call->reply().member() << call->error().message();
Expand Down
8 changes: 1 addition & 7 deletions calendar-common/src/huangliData/lunardatastruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@ typedef struct HuangLi {

typedef struct _tagHolidayInfo {
QDate date;
char status {};
uint status; // 1: 休 2: 补班
} HolidayInfo;

typedef struct _tagFestivalInfo {
QString ID {};
QString FestivalName {};
QString description {};
QString Rest {};
int month = 0;
int year = 0;
QVector<HolidayInfo> listHoliday {};
} FestivalInfo;

Expand Down
190 changes: 190 additions & 0 deletions calendar-service/assets/holiday-cn/2024.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
{
"$schema": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/schema.json",
"$id": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/2024.json",
"year": 2024,
"papers": [
"https://www.gov.cn/zhengce/zhengceku/202310/content_6911528.htm"
],
"days": [
{
"name": "元旦",
"date": "2024-01-01",
"isOffDay": true
},
{
"name": "春节",
"date": "2024-02-04",
"isOffDay": false
},
{
"name": "春节",
"date": "2024-02-10",
"isOffDay": true
},
{
"name": "春节",
"date": "2024-02-11",
"isOffDay": true
},
{
"name": "春节",
"date": "2024-02-12",
"isOffDay": true
},
{
"name": "春节",
"date": "2024-02-13",
"isOffDay": true
},
{
"name": "春节",
"date": "2024-02-14",
"isOffDay": true
},
{
"name": "春节",
"date": "2024-02-15",
"isOffDay": true
},
{
"name": "春节",
"date": "2024-02-16",
"isOffDay": true
},
{
"name": "春节",
"date": "2024-02-17",
"isOffDay": true
},
{
"name": "春节",
"date": "2024-02-18",
"isOffDay": false
},
{
"name": "清明节",
"date": "2024-04-04",
"isOffDay": true
},
{
"name": "清明节",
"date": "2024-04-05",
"isOffDay": true
},
{
"name": "清明节",
"date": "2024-04-06",
"isOffDay": true
},
{
"name": "清明节",
"date": "2024-04-07",
"isOffDay": false
},
{
"name": "劳动节",
"date": "2024-04-28",
"isOffDay": false
},
{
"name": "劳动节",
"date": "2024-05-01",
"isOffDay": true
},
{
"name": "劳动节",
"date": "2024-05-02",
"isOffDay": true
},
{
"name": "劳动节",
"date": "2024-05-03",
"isOffDay": true
},
{
"name": "劳动节",
"date": "2024-05-04",
"isOffDay": true
},
{
"name": "劳动节",
"date": "2024-05-05",
"isOffDay": true
},
{
"name": "劳动节",
"date": "2024-05-11",
"isOffDay": false
},
{
"name": "端午节",
"date": "2024-06-10",
"isOffDay": true
},
{
"name": "中秋节",
"date": "2024-09-14",
"isOffDay": false
},
{
"name": "中秋节",
"date": "2024-09-15",
"isOffDay": true
},
{
"name": "中秋节",
"date": "2024-09-16",
"isOffDay": true
},
{
"name": "中秋节",
"date": "2024-09-17",
"isOffDay": true
},
{
"name": "国庆节",
"date": "2024-09-29",
"isOffDay": false
},
{
"name": "国庆节",
"date": "2024-10-01",
"isOffDay": true
},
{
"name": "国庆节",
"date": "2024-10-02",
"isOffDay": true
},
{
"name": "国庆节",
"date": "2024-10-03",
"isOffDay": true
},
{
"name": "国庆节",
"date": "2024-10-04",
"isOffDay": true
},
{
"name": "国庆节",
"date": "2024-10-05",
"isOffDay": true
},
{
"name": "国庆节",
"date": "2024-10-06",
"isOffDay": true
},
{
"name": "国庆节",
"date": "2024-10-07",
"isOffDay": true
},
{
"name": "国庆节",
"date": "2024-10-12",
"isOffDay": false
}
]
}
1 change: 1 addition & 0 deletions calendar-service/assets/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>pinyin.dict</file>
<file>holiday-cn/2024.json</file>
</qresource>
</RCC>
Loading

0 comments on commit 7872dd6

Please sign in to comment.