示例#1
0
        /// <summary>
        /// Retrieves the current hardware time. If this is not possible,
        /// this method returns false.
        /// </summary>
        public static bool GetHardwareTime(Time time)
        {
            bool  result = false;
            ulong ct     = 0;

            if (time == null)
            {
                throw new ArgumentNullException("time");
            }

            time.Calendar = CalendarManager.GetCalendar(Calendar);

            result = RTC.Read(out time.Year, out time.Month, out time.Day, out time.Hour,
                              out time.Minute, out time.Second);
            time.DayOfWeek = time.Calendar.GetDayOfWeek(time);
            time.Calendar.AddStrings(time);

            ct = time.Ticks;

            if (HardwareIsUTC && Timezone != 0)
            {
                ct = SharpOS.Kernel.Foundation.Timezone.Localize(ct, Timezone);
                time.Set(ct);
            }

            return(result);
        }