CalendarΒΆ

Note

DateTime.TimeOfDay is not setted or changed by Calendar.

namespace UIWidgets.Examples
{
   using UnityEngine;

   /// <summary>
   /// Test Calendar.
   /// </summary>
   public class TestCalendar : MonoBehaviour
   {
      /// <summary>
      /// Calendart.
      /// </summary>
      [SerializeField]
      protected UIWidgets.Calendar Calendar;

      /// <summary>
      /// Start this instance.
      /// </summary>
      protected virtual void Start()
      {
         Calendar.OnDateChanged.AddListener(ProcessDate);

         // change first day of the week
         Calendar.FirstDayOfWeek = System.DayOfWeek.Sunday;

         // change culture
         Calendar.Culture = new System.Globalization.CultureInfo("en-US");

         // change calendar
         SetCalendar(new System.Globalization.JapaneseCalendar());
      }

      void ProcessDate(System.DateTime dt)
      {
         Debug.Log(dt);
      }

      void SetCalendar(System.Globalization.Calendar calendar)
      {
         Calendar.Culture.DateTimeFormat.Calendar = calendar;
         Calendar.UpdateCalendar();
      }
   }
}