package com.dgtly.common.utils;

import net.sf.json.JSONObject;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class FestivalUtil {

	// 判断当日日期类型：value =（0：工作日；1：双休日；2：节假日）
	public static int todayType() {
		Date now = new Date();
		Calendar cal = Calendar.getInstance();
		cal.setTime(now);
		if(cal.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY){
			return 0;
		}else{
			return 1;
		}
//		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//		String date = sdf.format(now);
//		JSONObject json = request(date);
//		int todayTape = Integer.parseInt(json.get("data").toString());
//		return todayTape;
	}




//	public static JSONObject request(String httpArg){
//		String str = httpArg.replace("-", "");
//		int date = Integer.parseInt(str);
//		String httpUrl = "http://api.goseek.cn/Tools/holiday";
//		BufferedReader reader = null;
//		String result = null;
//		JSONObject jsonObjectResult = null;
//		StringBuilder sb = new StringBuilder();
//		httpUrl = httpUrl + "?date=" + date;
//		try{
//			URL url = new URL(httpUrl);
//			HttpURLConnection connection = (HttpURLConnection) url.openConnection();
//			connection.setRequestMethod("GET");
//			connection.connect();
//			InputStream is = connection.getInputStream();
//			reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
//			String strRead = null;
//			while ((strRead = reader.readLine()) != null){
//				sb.append(strRead);
//				sb.append("\r\n");
//			}
//			reader.close();
//			result = sb.toString();
//			jsonObjectResult = JSONObject.fromObject(result);
//		}catch(Exception e){
//			e.printStackTrace();
//		} finally {
//			return jsonObjectResult;
//		}
//	}

}
