Exemple #1
0
    private IEnumerator Access()
    {
        //起点となる今月の1日目
        var first = new DateTime(calendarManager.GetcurrentYear(), calendarManager.GetcurrentMonth(), 1);

        current = first;                                                                //currentに日付を作成
        string buttonNum = PlayerPrefs.GetString("Index");                              //押したボタンのインデックスナンバー
        int    day       = int.Parse(PlayerPrefs.GetString("Day")) - 1;                 //押したボタンのテキスト(日にち)

        current = current.AddDays(day);

        Debug.Log("currentDay: " + current.Day);

        Dictionary <string, string> dic = new Dictionary <string, string>();

        //先月の日付なら月-1, 来月の日付なら月+1
        if (int.Parse(buttonNum) <= (int)first.DayOfWeek)
        {
            Debug.Log("先月");
            current = current.AddMonths(-1);
        }
        else if (current.Day > DateTime.DaysInMonth(current.Year, current.Month))
        {
            Debug.Log("来月");
            current = current.AddMonths(1);
        }

        //Dictionaryに格納します
        dic.Add("Year", current.Year.ToString());
        dic.Add("Month", current.Month.ToString());
        dic.Add("Day", current.Day.ToString());

        //Dictionary内の確認
        Debug.Log(dic["Year"] + dic["Month"] + dic["Day"]);

        //phpへのアクセス, Dictionary(年月日)を送る
        StartCoroutine(Post(ServerAddress, dic));

        yield return(0);
    }