Exemple #1
0
        public static bool calibrationTime()
        {
            StringBuilder sb = new StringBuilder();

            for (int idx = 0; idx <= NTP_SERVER_NO; idx++)
            {
                sb.Clear();
                SntpEntry = new SNTPClient(NTP_SERVERS[NTP_SERVER_NO]);
                try
                {
                    SntpEntry.Connect(false, 5000);
                }
                catch
                {
                    Console.WriteLine("[ERR] Time acquisition failure.");
                    continue;
                }
                if (debug)
                {
                    sb.Append(SntpEntry.ToString());
                }
                sb.Append(TrueDateTime.ToString());
                Console.WriteLine(sb.ToString());
                return(true);
            }
            return(false);
        }
Exemple #2
0
 public static bool calibrationTime()
 {
     StringBuilder sb = new StringBuilder();
     for (int idx = 0; idx <= NTP_SERVER_NO; idx++)
     {
         sb.Clear();
         SntpEntry = new SNTPClient(NTP_SERVERS[NTP_SERVER_NO]);
         try
         {
             SntpEntry.Connect(false, 5000);
         }
         catch
         {
             Console.WriteLine("[ERR] Time acquisition failure.");
             continue;
         }
         if (debug)
         {
             sb.Append(SntpEntry.ToString());
         }
         sb.Append(TrueDateTime.ToString());
         Console.WriteLine(sb.ToString());
         return true;
     }
     return false;
 }
Exemple #3
0
 public static DateTime getChineseTime()
 {
     SNTPClient sc = new SNTPClient(NTP_SERVERS[NTP_SERVER_NO]);
     sc.Connect(false);
     if (debug)
         Console.WriteLine(sc);
     return DateTime.Now.AddMilliseconds(sc.LocalClockOffset);
 }
Exemple #4
0
        public static DateTime getChineseTime()
        {
            SNTPClient sc = new SNTPClient(NTP_SERVERS[NTP_SERVER_NO]);

            sc.Connect(false);
            if (debug)
            {
                Console.WriteLine(sc);
            }
            return(DateTime.Now.AddMilliseconds(sc.LocalClockOffset));
        }