67 lines
1.3 KiB
C#
Raw Normal View History

2025-05-18 01:04:31 +08:00
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine.Networking;
namespace Calendar
{
public class Calendar
{
public int status { get; set; }
public List<CalendarData> data { get; set; }
}
public class CalendarData
{
//public Holiday holiday { get; set; }
public List<Holiday> holiday { get; set; }
}
public class Holiday
{
//public string desc { get; set; }
public string festival { get; set; }
public List<HolidayItem> list { get; set; }
public string name { get; set; }
//public string rest { get; set; }
}
public class HolidayItem
{
public string date { get; set; }
/// <summary>
/// 1休息2上班
/// </summary>
public int status { get; set; }
public string remark
{
get
{
return status == 1 ? "休假" : "上班";
}
}
}
public class CalendarUtil
{
public static System.Collections.IEnumerator CheckIsHoliday(DateTime time, Action<bool> callback)
{
var date = time.ToString("yyyyMMdd");
var url = $"https://tool.bitefu.net/jiari/?d={date}";
UnityWebRequest webRequest = UnityWebRequest.Get(url);
yield return webRequest.SendWebRequest();
if (webRequest.isNetworkError || webRequest.isHttpError)
{
callback(false);
yield break;
}
var data = webRequest.downloadHandler.text;
callback(data != "0");
}
}
}