Exemplo n.º 1
0
 private void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
 {
     lock (this)
     {
         hasTimeFixed = true;
     }
     Debug.Print("Time Fixed");
 }
Exemplo n.º 2
0
 private static void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
 {
     Trace("Network time received.");
     if (!timeSynchronized)
     {
         timeSynchronized = true;
         DoMqttStuff();
     }
 }
        /// <summary>
        /// TimeService System Time Changed Handler: signals through event "correct_time_event" the time correctness
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
        {
            lock (time_lock) {
                time_offset  = DateTime.UtcNow - last_wrong_time;
                correct_time = true;
            }
            /* Signal correct time */
            correct_time_event.Set();
#if (DEBUG)
            Debug.Print("DateTime = " + DateTime.Now.ToString());
#endif
        }
Exemplo n.º 4
0
        void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
        {
            // creating instance of manager
            TimeManager mgr = TimeManager.TimeMgr;

            // Updating current time
            mgr.UpdatedTime     = DateTime.Now.ToString("HH:mm:ss");
            Program.currentTime = DateTime.Now.ToString("HH:mm:ss");

            if (!mgr.IsTimeSync)
            {
                mgr.IsTimeSync = true;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// TimeService SystemTimeChanged Event, when the system time changes, we need to set offset depending on daylight savings
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">SystemTimeChangedEvent Arguments</param>
        private void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
        {
            //Daylight savings are the last sunday of march and october
            DateTime march   = new DateTime(DateTime.Now.Year, 3, 1);
            DateTime october = new DateTime(DateTime.Now.Year, 10, 1);
            //Get last sunday in both months
            DateTime daylightstart = LastDayInMonth(march, DayOfWeek.Sunday);
            DateTime daylightstop  = LastDayInMonth(october, DayOfWeek.Sunday);

            //If we are within thoose dates, add daylight saving time
            if (daylightstart.Ticks < DateTime.Now.Ticks && daylightstop.Ticks > DateTime.Now.Ticks)
            {
                TimeService.SetTimeZoneOffset(TimeZoneMinutes + DaylightSavingTime);
            }
            else
            {
                TimeService.SetTimeZoneOffset(TimeZoneMinutes);
            }
        }
Exemplo n.º 6
0
        private void OnSystemTimeChanged(Object sender, SystemTimeChangedEventArgs e)
        // Called on successful NTP Synchronization
        {
            var now = DateTime.Now; // Used to manipulate dates and time

            #region Check if we are in summer time and thus daylight savings apply

            // Check if we are in Daylight savings. The following algorithm works pour Europe and associated countries
            // In Europe, daylight savings (+60 min) starts the last Sunday of march and ends the last sunday of october

            var aprilFirst        = new DateTime(now.Year, 4, 1);
            var novemberFirst     = new DateTime(now.Year, 11, 1);
            var sundayshift       = new[] { 0, -1, -2, -3, -4, -5, -6 };
            var marchLastSunday   = aprilFirst.DayOfYear + sundayshift[(int)aprilFirst.DayOfWeek];
            var octoberLastSunday = novemberFirst.DayOfYear + sundayshift[(int)novemberFirst.DayOfWeek];

            if ((now.DayOfYear >= marchLastSunday) && (now.DayOfYear < octoberLastSunday))
            {
                _daylightSavingsShift = 60;
            }
            else
            {
                _daylightSavingsShift = 0;
            }

            TimeService.SetTimeZoneOffset(LocalTimeZone + _daylightSavingsShift);

            #endregion

            // Display the synchronized date on the Debug Console

            now = DateTime.Now;
            var date = now.ToString("dd/MM/yyyy");
            var here = now.ToString("HH:mm:ss");
            Debug.Print(date + " // " + here);
        }
 void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
 {
     Logger.TraceLog("Time: System Time Changed: " + e.EventTime);
 }
Exemplo n.º 8
0
 private void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
 {
     Program.setInternet(true);
     Debug.Print("Time is changed.\n");
 }
 private static void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
 {
     TimeChanged.Set( );
 }
Exemplo n.º 10
0
 private static void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
 {
     Debug.WriteLine("SystemTime has changed. Actual local Time is " + DateTime.Now);
     Debug.WriteLine("Actual utc Time is " + DateTime.UtcNow);
 }
Exemplo n.º 11
0
 private static void TimeService_SystemTimeChecked(object sender, SystemTimeChangedEventArgs e)
 {
     Debug.WriteLine("SystemTime was checked! " + DateTime.Now);
 }
Exemplo n.º 12
0
 static void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
 {
     Debug.Print("Ntp sync OK!");
 }
Exemplo n.º 13
0
 void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs evt)
 {
     Debug.Print("System Time Changed.");
 }
Exemplo n.º 14
0
 private static void onSystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
 {
     Debug.Print("System time changed by Time Service: " + DateTime.Now.ToString());
     isTimeSet = true;
 }
Exemplo n.º 15
0
 private static void TimeService_SystemTimeChanged(object sender, SystemTimeChangedEventArgs e)
 {
     Debug.Print("Time Synchronized -> " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
     Display.UpdateTimeStatus(true);
 }