示例#1
0
 public override string ToString()
 {
     return($"{DateSlot.ToShortDateString()} {TimeSlot}");
 }
示例#2
0
    void write_calendar(System.DateTime date, int target)
    {
        int month = int.Parse(date.Month.ToString());
        int year  = int.Parse(date.Year.ToString());

        GridLayoutGroup[] monthPages = gameObject.GetComponentsInChildren <GridLayoutGroup>();
        GridLayoutGroup   targetPage = monthPages[target];
        int    first_day_of_month    = Helper.Time.GetFirstDaysOfMonth(month, year);
        string first_date_of_month   = Helper.Time.GetDate(month.ToString() + "/1/" + year.ToString()).ToString();
        int    step = 0;

        foreach (Transform dateslot in targetPage.transform)
        {
            TextMeshProUGUI[] textInSlot = dateslot.GetComponentsInChildren <TextMeshProUGUI>();
            DateSlot          dateSlot   = dateslot.GetComponent <DateSlot>();
            TextMeshProUGUI   text       = textInSlot[0];
            System.DateTime   caldate    = Helper.Time.CalDate(first_date_of_month, step - first_day_of_month);
            text.text = caldate.ToString("dd");
            if (caldate.Month != month)
            {
                text.color = greyOut;
                step      += 1;
                continue;
            }
            if (caldate == Helper.Time.FullDate)
            {
                text.color = highlightToday;
            }
            if (PelanaiData.dateDataDict.ContainsKey(caldate.ToString("MM/dd/yyyy")))
            {
                int dateDataRate = PelanaiData.dateDataDict[caldate.ToString("MM/dd/yyyy")].rate;
                if (dateDataRate == 1)
                {
                    dateSlot.button.image.color = dateSlot.completeColor;
                }
                else if (dateDataRate == -1 && caldate != Helper.Time.FullDate)
                {
                    dateSlot.button.image.color = dateSlot.faliedColor;
                }
            }
            else if (PelanaiData.firstTimeLogin <= caldate.Date && caldate.Date < System.DateTime.Now.Date)
            {
                foreach (Activity activity in PelanaiData.activitiesList)
                {
                    if (activity.days.Contains(Helper.Time.GetintFromDay(caldate.DayOfWeek.ToString())))
                    {
                        dateSlot.button.image.color = dateSlot.faliedColor;
                        DateData dateData = new DateData(PelanaiData.activitiesList, caldate);
                        dateData.rate = -1;
                        break;
                    }
                    else
                    {
                        DateData dateData = new DateData(PelanaiData.activitiesList, caldate);
                        dateData.rate = 0;
                    }
                }
            }
            step += 1;
        }
    }