示例#1
0
        //Id des blocs en mémoires
        public GrilleHoraire(Graphics grfx, Loader loader, DateTime date)
        {
            gfx = grfx;
            this.loader = loader;
            //DateTime renvoyer par la fonction getweekrange()
            laDate = date;

            //DateTime et une addition de timespan
            DateTime lundi = laDate;
            DateTime mardi = laDate.Add(new TimeSpan(24, 0, 0));
            DateTime mercredi = laDate.Add(new TimeSpan(48, 0, 0));
            DateTime jeudi = laDate.Add(new TimeSpan(72, 0, 0));
            DateTime vendredi = laDate.Add(new TimeSpan(96, 0, 0));
            DateTime samedi = laDate.Add(new TimeSpan(120, 0, 0));
            DateTime dimanche = laDate.Subtract(new TimeSpan(24, 0, 0));

            //Création des jours - ajouter les blocs existants
            jours[0] = new GrilleJour("Dimanche", dimanche, 1, 40, 20, grfx, loader, this);
            jours[1] = new GrilleJour("Lundi", lundi, 2, 140, 20, grfx, loader, this);
            jours[2] = new GrilleJour("Mardi", mardi, 3, 240, 20, grfx, loader, this);
            jours[3] = new GrilleJour("Mercredi", mercredi, 4, 340, 20, grfx, loader, this);
            jours[4] = new GrilleJour("Jeudi", jeudi, 5, 440, 20, grfx, loader, this);
            jours[5] = new GrilleJour("Vendredi", vendredi, 6, 540, 20, grfx, loader, this);
            jours[6] = new GrilleJour("Samedi", samedi, 7, 640, 20, grfx, loader, this);
        }
示例#2
0
        public void GenerateNextEntrance(DateTime currentTime)
        {
            TimeSpan timeBetweenTwoEnter = TimeSpan.FromMinutes(Math.Round(RandomEngine.GetExpo(12))); // Const

            if (World.Instance != null)
            {
                if (World.Instance.MnuChkFastEntrance.IsChecked)
                {
                    while (timeBetweenTwoEnter.TotalMinutes > 30)
                    {
                        timeBetweenTwoEnter = TimeSpan.FromMinutes(Math.Round(RandomEngine.GetExpo(12)));
                    }
                }
            }

            DateTime entraneTime = currentTime.Add(timeBetweenTwoEnter);
            if (entraneTime > EndTime)
            {
                //NO More Entrance!
            }
            else
            {
                EventList.Add(new FutureEvent(Events.Arrival, currentTime.Add(timeBetweenTwoEnter)));
            }
        }
        internal override async Task StartPing()
        {
            _lastActivity = DateTime.Now.Add(_pingTimeout);
            _pingInterval = TimeSpan.FromMilliseconds(Math.Max(500, _pingTimeout.TotalMilliseconds / 2));

            while (_connection.IsConnected)
            {
                await Task.Delay(_pingInterval).ConfigureAwait(false);

                try
                {
                    var now = DateTime.Now;

                    if (_lastActivity.Add(_pingTimeout) < now)
                    {
                        _connection.Close(WebSocketCloseReasons.GoingAway);
                    }
                    else if (_lastActivity.Add(_pingInterval) < now)
                    {
                        _connection.WriteInternal(_pingBuffer, 0, true, false, WebSocketFrameOption.Ping, WebSocketExtensionFlags.None);
                    }
                }
                catch(Exception ex)
                {
                    DebugLog.Fail("BandwidthSavingPing.StartPing", ex);
                    _connection.Close(WebSocketCloseReasons.ProtocolError);
                }
            }

        }
示例#4
0
 private static bool IntersectDates(DateTime one, DateTime two, TimeSpan tone, TimeSpan ttwo)
 {
     if (one == two || one.Add(tone) == two.Add(ttwo))
     {
         return false;
     }
     else if (one < two)
     {
         if (one.Add(tone) > two)
         {
             return false;
         }
         if (one.Add(tone) > two.Add(ttwo))
         {
             return false;
         }
     }
     else
     {
         if (two.Add(ttwo) > one)
         {
             return false;
         }
         if (one.Add(tone) < two.Add(ttwo))
         {
             return false;
         }
     }
     return true;
 }
示例#5
0
        private void Image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (cyclePivot.Items.Count == 0)
            {
                MessageBox.Show("Please define at least one cycle before continuing", "No cycles have been defined", MessageBoxButton.OK);
                return;
            }
            dateTimeRunning = DateTime.Now;
            dateTimeEnd = dateTimeRunning.Add((TimeSpan)timeSpanPicker.Value);
            int i = currentCycle;
            //for (int i = 0; i < App.ViewModel.CycleCounter - 1; i++)
            //{
            DateTime dtEnd = dateTimeEndCycles[i];
            DateTime dtRunning = dateTimeRunningCycles[i];
            PivotItem pItem = (PivotItem)cyclePivot.Items[i];
            TimeSpanPicker picker = (TimeSpanPicker)pItem.Content;
            dateTimeEndCycles[i] = dateTimeRunning.Add((TimeSpan)picker.Value);
            dateTimeRunningCycles[i] = DateTime.Now;
            //}

            //Time is zero, so exit
            if (timeSpanPicker.Value == TimeSpan.FromTicks(0))
                return;

            PlayPause.Source = (ImageSource)new ImageSourceConverter().ConvertFromString("Images/appbar.transport.pause.rest.png");
            if (!dispatcherTimer.IsEnabled)
            {
                dispatcherTimer.Start();
            }
            else
            {
                dispatcherTimer.Stop();
                PlayPause.Source = (ImageSource)new ImageSourceConverter().ConvertFromString("Images/appbar.transport.play.rest.png");
            }
        }
示例#6
0
文件: EchoGuide.cs 项目: drdax/Radio
		protected override async Task FillGuide(DateTime date) {
			Queue<TimeSpan> newsQueue=new Queue<TimeSpan>(5); TimeSpan previousTime=new TimeSpan(-1);
			foreach (Match match in broadcastRx.Matches(
				await client.DownloadStringTaskAsync(string.Concat("http://echo.msk.ru/schedule/", date.ToString(@"yyyy\-MM\-dd"), ".html")))) {
				GroupCollection groups=match.Groups;
				string title=htmlRx.Replace(groups["title"].Success ? groups["title"].Value:groups["notice"].Value, string.Empty);
				Match newsMatch=newsRx.Match(title);
				if (newsMatch.Success) {
					newsQueue.Clear();
					title=newsMatch.Groups["caption"].Value;
					foreach (Capture cap in newsMatch.Groups["time"].Captures)
						newsQueue.Enqueue(TimeSpan.Parse(cap.Value.Substring(0, 5))); // Substring lai atstātu tikai laiku.
				}

				var sb=new StringBuilder();
				if (groups["title"].Success && groups["notice"].Value.Length != 0) sb.Append(groups["notice"].Value);
				AddPeople("guests", "Гость ", "Гости ", sb, groups);
				AddPeople("presenters", "Ведущий ", "Ведущие ", sb, groups);

				TimeSpan time=TimeSpan.Parse(groups["time"].Value);
				while (newsQueue.Count != 0 && time >= newsQueue.Peek()) {
					TimeSpan newsTime=newsQueue.Dequeue();
					if (time != newsTime) AddBroadcast(date.Add(newsTime), "Новости", null, null);
				}
				if (time == previousTime) continue;
				AddBroadcast(date.Add(time),
					quoteRx.Replace(title.Replace("&quot;", "\""), "«$1»"),
					sb.Length != 0 ? sb.ToString():null,
					groups["url"].Success ? groups["url"].Value:null);
				previousTime=time;
			}
		}
示例#7
0
        public bool IsRoomAvailable(Guid eventId, Room room, DateTime start, DateTime end)
        {
            if (room.EndTime < room.StartTime)
            {
                if (room.EndTime < room.StartTime)
                {
                    if ((new TimeSpan(start.Hour, start.Minute, 0)).Ticks < (new TimeSpan(room.StartTime.Hours, room.StartTime.Minutes, room.StartTime.Seconds)).Ticks)
                        start = start.AddDays(1);
                    if ((new TimeSpan(end.Hour, end.Minute, 0)).Ticks < (new TimeSpan(room.StartTime.Hours, room.StartTime.Minutes, room.StartTime.Seconds)).Ticks)
                        end = end.AddDays(1);
                }
            }

            var isEventRoomBooked = BookedRooms.Where(x => !x.EventRoom.Event.IsDeleted && x.EventRoom.EventID != eventId && x.EventRoom.RoomID == room.ID).Any(x => IsDateBetweenAnotherTwo(start, end, x.StartTimeEx)
                || IsDateBetweenAnotherTwo(x.StartTimeEx, x.EndTimeEx, start) || IsDateBetweenAnotherTwo(x.StartTimeEx, x.EndTimeEx, end.Add(new TimeSpan(0, 0, -1, 0)))
                            || IsDateBetweenAnotherTwo(start, end, x.EndTimeEx.Add(new TimeSpan(0, 0, -1, 0))));

            var isEventCateringBooked = BookedCaterings.Where(x => !x.EventCatering.Event.IsDeleted && x.EventCatering.EventID != eventId && x.EventCatering.RoomID == room.ID).Any(x => IsDateBetweenAnotherTwo(start, end, x.StartTimeEx)
                || IsDateBetweenAnotherTwo(x.StartTimeEx, x.EndTimeEx, start) || IsDateBetweenAnotherTwo(x.StartTimeEx, x.EndTimeEx, end.Add(new TimeSpan(0, 0, -1, 0)))
                || IsDateBetweenAnotherTwo(start, end, x.EndTimeEx.Add(new TimeSpan(0, 0, -1, 0))));

            var isRoomBooked = isEventRoomBooked || isEventCateringBooked;

            return !isRoomBooked;
        }
示例#8
0
 public static DateTime ConvertFromSubsonicTimestamp(double timestamp, bool asLocalTime = true)
 {
     DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
     TimeSpan ts = TimeSpan.FromSeconds(timestamp / 1000); //subsonic seems to measure in ms rather than seconds
     if (asLocalTime)
         return origin.Add(ts).ToLocalTime();
     return origin.Add(ts);
 }
示例#9
0
文件: MayakGuide.cs 项目: drdax/Radio
		protected override async Task FillGuide(DateTime date) {
			// Nolasīto bloku saturs. Viens [bloka] raidījums var būt vairākas reizes dienā, bet tam atbilst viena bloka lappuse.
			var episodes=new Dictionary<int, Episode>(12);
			bool previousIsPast=true; // Vai iepriekšējais bloks ir pagātnē. Lieto pašreizējā bloka noteikšanai (jo tas nekā neizceļās).
			string episodeCaption=null; // Pašreizējā bloka nosaukums.
			var sb=new StringBuilder(200);

			foreach (var xEpisode in await GetFragments("http://radiomayak.ru/schedule/index/date/"+date.ToString("dd-MM-yyyy"))) {
				string className=xEpisode.Attribute("class").Value;
				if (className == "b-schedule__list-sub-list") {
					// Dienas programmā pašreizējais bloks ir izvērsts, paņem no tā visus raidījumus.
					foreach (var fragment in xEpisode.Elements("div")) {
						var data=fragment.Element("div").Elements("div");
						AddBroadcast(date.Add(TimeSpan.Parse(data.ElementAt(0).Value.Substring(0, 5))), // hh:mm
							GetCaption(data, episodeCaption), GetDescription(data, sb));
					}
				} else {
					var data=xEpisode.Element("div").Elements("div");
					var link=data.ElementAt(1).Element("h5").Element("a");
					if (previousIsPast && !className.EndsWith("past-show")) {
						// Tā kā pirmais bloka raidījums sākas kopā ar bloku, iegaumē tikai tā nosaukumu.
						episodeCaption=link.Value;
					} else {
						if (episodeCaption == null) {
							// Raidījumiem pirms pašreizējā paņem tikai bloka laiku un nosaukumu.
							AddBroadcast(date.Add(TimeSpan.Parse(data.ElementAt(0).Value)), // hh:mm
								link.Value, null);
						} else {
							episodeCaption=link.Value;
							string episodeTime=data.ElementAt(0).Value; // hh:mm

							int id=int.Parse(idRx.Match(link.Attribute("href").Value).Groups[1].Value);
							Episode episode;
							if (!episodes.TryGetValue(id, out episode)) {
								// Nākošajiem raidījumiem bloka saturu izgūst no atsevišķas lappuses.
								episode=new Episode(await GetFragments("http://radiomayak.ru"+link.Attribute("href").Value));
								episodes.Add(id, episode);
							}

							bool inBlock=false; // Vai pašreizējie bloka raidījumi atbilst atlasāmajam laikam.
							for (int n=episode.StartIdx; n < episode.FragmentsCount; n++) {
								var fragment=episode.Fragments.ElementAt(n);
								data=fragment.Element("div").Elements("div");
								if (data.Count() == 2) { // Starp blokiem ir atdalītāji, kurus veido mazāk div elementu.
									if (inBlock) { episode.StartIdx=n+1; break; }
									continue;
								}
								string fragmentTime=data.ElementAt(0).Value.Substring(0, 5); // hh:mm (Substring nogriež atdalītāju un beigu laiku)
								if (episodeTime == fragmentTime) inBlock=true;
								if (inBlock)
									AddBroadcast(date.Add(TimeSpan.Parse(fragmentTime)), GetCaption(data, episodeCaption), GetDescription(data, sb));
							}
						}
					}
					previousIsPast=className.EndsWith("past-show");
				}
			}
		}
示例#10
0
        public void AreEqualsValidatesDatesWithinThreshold()
        {
            var date1 = new DateTime(2016, 3, 1, 12, 34, 56);
            var date2 = date1.Add(1.Seconds());
            LoggerAssert.AreEqual(date1, date2, 2.Seconds(), "Dates should be equal +/- 2 seconds");

            var date3 = date1.Add(5.Seconds());
            TestUtils.ExpectException<AssertFailedException>(() => LoggerAssert.AreEqual(date1, date3, 2.Seconds(), "This assert should fail!"),
                "5 seconds are too big a difference...");
        }
示例#11
0
文件: Program.cs 项目: helios57/anrl
        static void Main(string[] args)
        {
            long javams = 1339714653449L;
            DateTime UTCBaseTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            DateTime dt = UTCBaseTime.Add(new TimeSpan(javams * TimeSpan.TicksPerMillisecond)).ToLocalTime();

            System.Console.Out.WriteLine(dt.Ticks);
            System.Console.Out.WriteLine(DateTime.Now.Ticks);

            System.Console.Out.WriteLine(DateTime.Parse("2012.06.14 02:57:23"));
            System.Console.Out.WriteLine(new DateTime(dt.Ticks));
            System.Console.Out.WriteLine(new DateTime(DateTime.Now.Ticks));

            double Latitude = ConvertCoordinates("N4753.0418");
            double Longitude = ConvertCoordinates("E00820.8429");
            double Altitude = double.Parse("1015.4", NumberFormatInfo.InvariantInfo);

            System.Console.Out.WriteLine(new DateTime(634755390850000000).AddDays(-1));
            System.Console.Out.WriteLine(new DateTime(UTCBaseTime.Add(new TimeSpan(1339942290000L * TimeSpan.TicksPerMillisecond)).Ticks));

            // Type serviceType = typeof(LiveInputService.LiveInputServiceImpl);
            // ServiceHost host = new ServiceHost(serviceType,new Uri[]{new Uri("gps")});
            //host.Open();
            // AnrlService.AnrlServiceImpl service = new AnrlService.AnrlServiceImpl();
            // service.start();
            Thread.Sleep(Int32.MaxValue);
            /*int PORT = 1337;
            TcpListener server;
            server = new TcpListener(IPAddress.Any, PORT);
            server.Start();
            server.BeginAcceptTcpClient(ClientConnected, server);
            Thread.Sleep(Int32.MaxValue);
            /*
            AnrlDB.AnrlDataContext db = new AnrlDB.AnrlDataContext();
            db.DatabaseExists();
            db.CreateDatabase();*/

            /*
            string path = @"C:\Users\Helios6x\Downloads\flags_style1_medium";
            DirectoryInfo dir = new DirectoryInfo(path);
            AnrlDB.AnrlDataContext db = new AnrlDB.AnrlDataContext();
            foreach (FileInfo fi in dir.GetFiles().Where(p=>p.Extension==".png"))
            {
                Image i = Image.FromFile(fi.FullName);
                t_Picture pic = new t_Picture();
                pic.Name = fi.Name.Replace(fi.Extension,"").Trim();
                pic.isFlag = true;

                MemoryStream ms = new MemoryStream();
                i.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                pic.Data = ms.ToArray();
                db.t_Pictures.InsertOnSubmit(pic);
            }
            db.SubmitChanges();*/
        }
示例#12
0
        private myCoord getCorner()
        {
            const float   eps    = 0.00006f;                             //epsilon value, dictates precision for the variance
            myCoord       sample = new myCoord();                        //sample data we get after each time span
            Queue <float> xQueue = new Queue <float>(10);                //queues for the x, y, z values
            Queue <float> yQueue = new Queue <float>(10);                //we get data every 0.2 seconds, and stop when we detect that the
            Queue <float> zQueue = new Queue <float>(10);                //hand has stayed still for 2 seconds, hence analyse the last 10 values

            System.DateTime t1   = System.DateTime.Now;                  //current time
            System.TimeSpan span = new System.TimeSpan(0, 0, 0, 0, 200); //time span of 0.2 seconds between each sampling of the position
            System.DateTime t3   = new System.DateTime();                //time at which we have to get the new sample

            //fill the queues with the initial 10 samples
            while (xQueue.Count < 10)
            {
                t3 = t1.Add(span);                                                      //when we get the next round of data
                xQueue.Enqueue(xCoord); yQueue.Enqueue(yCoord); zQueue.Enqueue(zCoord); //get current round of data

                //wait until next round
                while (t1 < t3)
                {
                    t1 = System.DateTime.Now;
                }
            }

            //compute the initial variances of position data
            float xVar = Variance(xQueue);
            float yVar = Variance(yQueue);
            float zVar = Variance(zQueue);

            //while the variances are to high, meaning the hand isn't still, keep tracking the hand
            while ((xVar > eps | yVar > eps | zVar > eps) || (xQueue.Average() == 0 && yQueue.Average() == 0 && zQueue.Average() == 0))
            {
                t3 = t1.Add(span);                                                         //when we get next round of data

                xQueue.Dequeue(); yQueue.Dequeue(); zQueue.Dequeue();                      //discard old data
                xQueue.Enqueue(xCoord); yQueue.Enqueue(yCoord); zQueue.Enqueue(zCoord);    //get current round
                xVar = Variance(xQueue); yVar = Variance(yQueue); zVar = Variance(zQueue); //compute new variance

                //wait until next round
                while (t1 < t3)
                {
                    t1 = System.DateTime.Now;
                }
            }

            //when the hand hasn't moved return it's position, averaging over the last 10 positions
            sample.X = xQueue.Average();
            sample.Y = yQueue.Average();
            sample.Z = zQueue.Average();

            Console.Beep();     //give an audio confirmation to the user
            return(sample);
        }
示例#13
0
        public static bool CheckAvail(this TableAvailability ta, DateTime date, DateTime startTime, DateTime endTime)
        {
            var TAStartTime = date.Add(DateTime.ParseExact(ta.StartTime.Trim(), "h:mm tt", CultureInfo.InvariantCulture).TimeOfDay);
            var TAEndTime = date.Add(DateTime.ParseExact(ta.EndTime.Trim(), "h:mm tt", CultureInfo.InvariantCulture).TimeOfDay);

            if ((TAStartTime <= startTime && TAEndTime >= endTime)
                || (TAStartTime >= startTime && TAEndTime <= endTime)
                || (TAStartTime < startTime && TAEndTime > startTime)
                || (TAStartTime < endTime && TAEndTime > endTime))
                return true;
            else
                return false;
        }
示例#14
0
        public EPGEntry(ushort service, string name, string description, DateTime start, TimeSpan duration)
        {
            // Main
            Text = string.Format("{0} (0x{0:x})", service);

            // Load all
            SubItems.Add(start.ToString());
            SubItems.Add(start.Add(duration).TimeOfDay.ToString());
            SubItems.Add(name);
            SubItems.Add(description);

            // Create for compare
            CompareData = new object[] { service, start, start.Add(duration), name };
        }
        public void SetSuccessTest()
        {
            TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(System.DateTime.Now);

            System.DateTime timeStamp1 = new System.DateTime(2014, 6, 17, 23, 42, 33);
            System.DateTime timeStamp2 = new System.DateTime(2014, 6, 17, 23, 44, 35);
            System.DateTime timeStamp3 = new System.DateTime(2014, 6, 17, 23, 59, 01);

            using (mocks.Ordered)
            {
                Expect.Once.On(mockDateTime).GetProperty("UtcNow").Will(Return.Value(timeStamp1));
                Expect.Once.On(mockDateTime).GetProperty("UtcNow").Will(Return.Value(timeStamp2));
                Expect.Once.On(mockDateTime).GetProperty("UtcNow").Will(Return.Value(timeStamp3));
                Expect.Once.On(mockStreamWriter).Method("WriteLine").With(timeStamp1.Add(utcOffset).ToString(dateTimeFormat) + " | " + new TestAvailableMemoryMetric(0).Name + " | " + 301156000);
                Expect.Once.On(mockStreamWriter).Method("Flush");
                Expect.Once.On(mockStreamWriter).Method("WriteLine").With(timeStamp2.Add(utcOffset).ToString(dateTimeFormat) + " | " + new TestFreeWorkerThreadsMetric(0).Name + " | " + 12);
                Expect.Once.On(mockStreamWriter).Method("Flush");
                Expect.Once.On(mockStreamWriter).Method("WriteLine").With(timeStamp3.Add(utcOffset).ToString(dateTimeFormat) + " | " + new TestAvailableMemoryMetric(0).Name + " | " + 301155987);
                Expect.Once.On(mockStreamWriter).Method("Flush").Will(Signal.EventWaitHandle(workerThreadLoopCompleteSignal));
            }

            testFileMetricLogger.Set(new TestAvailableMemoryMetric(301156000));
            testFileMetricLogger.Set(new TestFreeWorkerThreadsMetric(12));
            testFileMetricLogger.Set(new TestAvailableMemoryMetric(301155987));
            testFileMetricLogger.Start();
            workerThreadLoopCompleteSignal.WaitOne();

            mocks.VerifyAllExpectationsHaveBeenMet();
            Assert.IsNull(exceptionStorer.StoredException);
        }
        public void AddSuccessTest()
        {
            TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(System.DateTime.Now);

            System.DateTime timeStamp1 = new System.DateTime(2014, 6, 14, 12, 45, 31);
            System.DateTime timeStamp2 = new System.DateTime(2014, 6, 14, 12, 45, 43);
            System.DateTime timeStamp3 = new System.DateTime(2014, 6, 15, 23, 58, 47);

            using (mocks.Ordered)
            {
                Expect.Once.On(mockDateTime).GetProperty("UtcNow").Will(Return.Value(timeStamp1));
                Expect.Once.On(mockDateTime).GetProperty("UtcNow").Will(Return.Value(timeStamp2));
                Expect.Once.On(mockDateTime).GetProperty("UtcNow").Will(Return.Value(timeStamp3));
                Expect.Once.On(mockStreamWriter).Method("WriteLine").With(timeStamp1.Add(utcOffset).ToString(dateTimeFormat) + " | " + new TestMessageBytesReceivedMetric(0).Name + " | " + 12345);
                Expect.Once.On(mockStreamWriter).Method("Flush");
                Expect.Once.On(mockStreamWriter).Method("WriteLine").With(timeStamp2.Add(utcOffset).ToString(dateTimeFormat) + " | " + new TestDiskBytesReadMetric(0).Name + " | " + 160307);
                Expect.Once.On(mockStreamWriter).Method("Flush");
                Expect.Once.On(mockStreamWriter).Method("WriteLine").With(timeStamp3.Add(utcOffset).ToString(dateTimeFormat) + " | " + new TestMessageBytesReceivedMetric(0).Name + " | " + 12347);
                Expect.Once.On(mockStreamWriter).Method("Flush").Will(Signal.EventWaitHandle(workerThreadLoopCompleteSignal));
            }

            testFileMetricLogger.Add(new TestMessageBytesReceivedMetric(12345));
            testFileMetricLogger.Add(new TestDiskBytesReadMetric(160307));
            testFileMetricLogger.Add(new TestMessageBytesReceivedMetric(12347));
            testFileMetricLogger.Start();
            workerThreadLoopCompleteSignal.WaitOne();

            mocks.VerifyAllExpectationsHaveBeenMet();
            Assert.IsNull(exceptionStorer.StoredException);
        }
    void endTrial()
    {
        StopTrialTimer();
        onTrial = false;

        if (!onTraining)
        {
            Trajectory traj = new Trajectory();
            traj.participantID        = participantID;
            traj.sessionNumber        = sessionNumber;
            traj.trialID              = trialID;
            traj.blockID              = blockID;
            traj.trajectoryPositions  = trajectoryPositions;
            traj.trajectoryTimeStamps = trajectoryTimeStamps;
            traj.yawData              = yawData;
            traj.export();

            Trial trial = new Trial();
            trial.participantID    = participantID;
            trial.sessionNumber    = sessionNumber;
            trial.trialID          = trialID;
            trial.blockID          = blockID;
            trial.FOVCondition     = (ExperimentSettings.FovRestriction?"RY":"RN");
            trial.startTime        = trialStartTime;
            trial.endTime          = trialStartTime.Add(new System.TimeSpan(0, 0, 0, (int)elapsed));
            trial.completionTime   = elapsed;
            trial.platformLocation = platform.transform.position;
            trial.insertionPoint   = trialInsertionPoint;
            trial.export();
        }
    }
示例#18
0
 // Function to check whether unlimited energy is active
 public void checkUnlimitedEnergy()
 {
     if (System.DateTime.Now.CompareTo(unlimitedEnergyStart.Add(unlimitedEnergySpan)) > 0)
     {
         isUnlimitedEnergy = false;
     }
 }
 private async Task DelayAction()
 {
     stamp = DateTime.Now;
     isRefreshed = true;
     if (isWaiting)
     {
         return;
     }
     isWaiting = true;
     try
     {
         while (isRefreshed)
         {
             isRefreshed = false;
             var toWait = (stamp.Add(sizeChangeDelay) - DateTime.Now);
             if (toWait.Ticks > 0)
             {
                 await Task.Delay(toWait);
             }
         }
     }
     finally
     {
         isWaiting = false;
     }
     OnSizeUpdated();
 }
示例#20
0
        static void Main(string[] args)
        {
            //Posun v ČZ
            Console.WriteLine(DateTime.Now);
            Console.WriteLine("Posun v časové zóně");
            string TZ;

            TZ = Console.ReadLine();
            int TZR = int.Parse(TZ);

            DateTime date = new System.DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(1557458354);

            TimeSpan time = new TimeSpan(0, TZR, 0, 0);

            DateTime final = date.Add(time);

            Console.WriteLine(String.Format("{0:d/M/yyyy HH:mm:ss}", final));
            Console.ReadKey();


            //API podle zadání
            string mesto = Console.ReadLine();
            string json;

            new Item = Items;


            json  = new WebClient().DownloadString("http://api.openweathermap.org/data/2.5/forecast?q={mesto}&APPID=fedcf81469d34db86a7e24886bb9ae83");
            Items = JsonConvert.DeserialObject <Item>(json);
        }
 public static DateTime GetBuildDate()
 {
     System.Version  version   = Assembly.GetExecutingAssembly().GetName().Version;
     System.DateTime startDate = new System.DateTime(2000, 1, 1, 0, 0, 0);
     System.TimeSpan span      = new System.TimeSpan(version.Build, 0, 0, version.Revision * 2);
     return(startDate.Add(span));
 }
 ///   <summary>   
 ///   計算本周結束日期(禮拜日的日期)   
 ///   </summary>   
 ///   <param   name="someDate">該周中任意一天</param>   
 ///   <returns>返回禮拜日日期,後面的具體時、分、秒和傳入值相等</returns>   
 public static DateTime CalculateLastDateOfWeek(DateTime someDate)
 {
     int i = someDate.DayOfWeek - DayOfWeek.Sunday;
     if (i != 0) i = 7 - i;//   因為枚舉原因,Sunday排在最前,相減間隔要被7減。
     TimeSpan ts = new TimeSpan(i, 0, 0, 0);
     return someDate.Add(ts);
 }
示例#23
0
        private DateTime GetDateTime(DateTime airDate, string airTime)
        {
            if (String.IsNullOrWhiteSpace(airTime))
                return airDate;

            return airDate.Add(Convert.ToDateTime(airTime).TimeOfDay);
        }
示例#24
0
        public List<EventWrapper> GetList(DateTime utcStartDate, DateTime utcEndDate)
        {
            var list = new List<EventWrapper>();

            if (_baseEvent.UtcStartDate == DateTime.MinValue)
                return list;

            var difference = _baseEvent.UtcEndDate - _baseEvent.UtcStartDate;

            var localStartDate = _baseEvent.UtcStartDate.Kind == DateTimeKind.Local ? _baseEvent.UtcStartDate : _baseEvent.UtcStartDate.Add(_timeZone.BaseUtcOffset);

            var recurenceDates = _baseEvent.RecurrenceRule.GetDates(localStartDate, utcStartDate.Add(_timeZone.BaseUtcOffset), utcEndDate.Add(_timeZone.BaseUtcOffset));

            if(recurenceDates.Count==0)
                recurenceDates.Add(localStartDate);

            foreach (var d in recurenceDates)
            {
                var utcD = d.AddMinutes((-1) * (int)_timeZone.BaseUtcOffset.TotalMinutes);
                var endDate = _baseEvent.UtcEndDate;
                if (!_baseEvent.UtcEndDate.Equals(DateTime.MinValue))
                    endDate = utcD + difference;

                list.Add(new EventWrapper(_baseEvent, this.UserId, _timeZone, utcD, endDate));
            }

            return list;
        }
示例#25
0
        private static DateTime NestCalStartTime(DateTime startTime, DateTime baseTime, List<RestTime> restTimeList)
        {
            if (startTime == baseTime)
            {
                return startTime;
            }
            if (restTimeList != null && restTimeList.Count > 0)
            {
                List<RestTime> restTimes = restTimeList.Where(rt => rt.StartTime < baseTime
                    && rt.EndTime > startTime).ToList();

                if (restTimes != null && restTimes.Count > 0)
                {
                    DateTime newStartTime = new DateTime(startTime.Ticks);
                    foreach (RestTime rt in restTimes)
                    {
                        newStartTime = newStartTime.Add(-(rt.EndTime > baseTime ? baseTime : rt.EndTime).Subtract((rt.StartTime > startTime ? rt.StartTime : startTime)));
                    }

                    startTime = NestCalStartTime(newStartTime, startTime, restTimeList);
                }
            }

            return startTime;
        }
示例#26
0
 private async Task DelayAction()
 {
     stamp = DateTime.Now;
     isRefreshed = true;
     if (isWaiting)
     {
         return;
     }
     isWaiting = true;
     try
     {
         while (isRefreshed)
         {
             isRefreshed = false;
             var toWait = (stamp.Add(eventDelay) - DateTime.Now);
             if (toWait.Ticks > 0)
             {
                 await Task.Delay(toWait);
             }
         }
     }
     finally
     {
         isWaiting = false;
     }
     AppHelpers.DispatchAction(FireEvent, false, 0);
 }
示例#27
0
        private bool SetNewAffiliate(string referrerId, string referrerUrl, MerchantTribeApplication app)
        {
            Contacts.Affiliate aff = Affiliates.FindByReferralId(referrerId);
            if (aff == null)
            {
                return(false);
            }
            if (!aff.Enabled)
            {
                return(false);
            }

            if (aff.Id != SessionManager.CurrentAffiliateID(app.CurrentStore))
            {
                System.DateTime expires = System.DateTime.UtcNow;
                if (aff.ReferralDays > 0)
                {
                    TimeSpan ts = new TimeSpan(aff.ReferralDays, 0, 0, 0);
                    expires = expires.Add(ts);
                }
                else
                {
                    expires = System.DateTime.UtcNow.AddYears(50);
                }
                SessionManager.SetCurrentAffiliateId(aff.Id, expires, app.CurrentStore);
            }
            return(LogReferral(aff.Id, referrerUrl));
        }
示例#28
0
 public TimeSpan GetTimeUntilNextOccurrence(DateTime specificTime)
 {
     var twoDays = TimeSpan.FromDays(2);
     DateTime futureDate = specificTime.Add(twoDays);
     DateTime timeoutDate = GetNextOccurrence(futureDate);
     return timeoutDate - specificTime;
 }
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
 {
     Dictionary<string, object> timeHashValue = serializer.Deserialize<Dictionary<string, object>>(reader);
     if (timeHashValue == null)
     {
         return DateTime.MinValue;
     }
     if (timeHashValue.ContainsKey("time") && timeHashValue.ContainsKey("year") && timeHashValue.ContainsKey("month") && timeHashValue.ContainsKey("date")
          && timeHashValue.ContainsKey("hours") && timeHashValue.ContainsKey("minutes") && timeHashValue.ContainsKey("seconds"))
     {
         long time = Convert.ToInt64(timeHashValue["time"]);
         int year = Convert.ToInt32(timeHashValue["year"]);
         int month = Convert.ToInt32(timeHashValue["month"]);
         int day = Convert.ToInt32(timeHashValue["date"]);
         int hours = Convert.ToInt32(timeHashValue["hours"]);
         int minutes = Convert.ToInt32(timeHashValue["minutes"]);
         int seconds = Convert.ToInt32(timeHashValue["seconds"]);
         TimeSpan span = new TimeSpan(time);
         DateTime times;
         try
         {
             times = new DateTime(year, month, day, hours, minutes, seconds);
         }
         catch
         {
             times = DateTime.MinValue;
         }
         return times.Add(span);
     }
     else
     {
         return DateTime.MinValue;
     }
 }
示例#30
0
 public void AddEvent(DateTime date, string title, string location)
 {
     Event newEvent = new Event(date, title, location);
     title.Add(title.ToLower(), newEvent);
     date.Add(newEvent);
     Messages.EventAdded();
 }
示例#31
0
文件: DateTimeSpan.cs 项目: q2git/VS
 static void Main()
 {
     System.DateTime today    = System.DateTime.Now;
     System.TimeSpan duration = TimeSpan.Parse("36.00:00:00");
     System.DateTime answer   = today.Add(duration);
     System.Console.WriteLine("{0}  {0:dddd}", answer, answer);
 }
示例#32
0
        public static DateTime GetRealArrivalTime(DateTime ArriveTime)
        {
            DateTimeOffset DtOffset = new DateTimeOffset(ArriveTime, TimeSpan.Zero);
            TimeSpan UtcOffset = TimeZoneInfo.Local.GetUtcOffset(DtOffset);

            return ArriveTime.Add(UtcOffset);
        }
示例#33
0
        public void SchoolDayLessonsTest()
        {
            TimeSpan lessonDuration = Duration.Minutes( 50 );
            TimeSpan shortBreakDuration = Duration.Minutes( 5 );
            TimeSpan largeBreakDuration = Duration.Minutes( 15 );
            DateTime now = ClockProxy.Clock.Now;
            DateTime todaySchoolStart = new DateTime( now.Year, now.Month, now.Day, 8, 0, 0 );

            TimeBlock lesson1 = new TimeBlock( todaySchoolStart, lessonDuration );
            TimeBlock break1 = new TimeBlock( lesson1.End, shortBreakDuration );
            TimeBlock lesson2 = new TimeBlock( break1.End, lessonDuration );
            TimeBlock break2 = new TimeBlock( lesson2.End, largeBreakDuration );
            TimeBlock lesson3 = new TimeBlock( break2.End, lessonDuration );
            TimeBlock break3 = new TimeBlock( lesson3.End, shortBreakDuration );
            TimeBlock lesson4 = new TimeBlock( break3.End, lessonDuration );

            Assert.AreEqual( lesson4.End,
                todaySchoolStart.Add( lessonDuration ).
                Add( shortBreakDuration ).
                Add( lessonDuration ).
                Add( largeBreakDuration ).
                Add( lessonDuration ).
                Add( shortBreakDuration ).
                Add( lessonDuration ) );
        }
示例#34
0
文件: RusGuide.cs 项目: drdax/Radio
		protected override async Task FillGuide(DateTime date) {
			foreach (Match match in broadcastRx.Matches(await client.DownloadStringTaskAsync(url+date.ToString("yyyy-MM-dd\\/"))))
				AddBroadcast(date.Add(TimeSpan.Parse(match.Groups["time"].Value)),
					Quotes.Format(match.Groups["caption"].Value),
					Quotes.Format(match.Groups["description"].Value.TrimEnd().Replace("''", "\"")),
					match.Groups["url"].Success ? match.Groups["url"].Value:null);
		}
示例#35
0
文件: TimeZone.cs 项目: x335/WootzJs
        /// <summary>
        /// Returns the local time that corresponds to a specified date and time value.
        /// </summary>
        /// 
        /// <returns>
        /// A <see cref="T:System.DateTime"/> object whose value is the local time that corresponds to <paramref name="time"/>.
        /// </returns>
        /// <param name="time">A Coordinated Universal Time (UTC) time. </param><filterpriority>2</filterpriority>
        public virtual DateTime ToLocalTime(DateTime time)
        {
            if (time.Kind == DateTimeKind.Local)
                return time;

            return time.Add(offset);
        }
示例#36
0
 public DateTime UtcTicksToDateTime(long seconds)
 {
     var ts = TimeSpan.FromSeconds(seconds);
     var epoc = new DateTime(1970, 1, 1, 0, 0, 0, 0);
     epoc = epoc.Add(ts);
     return epoc;
 }
示例#37
0
        public static void recordEvent(TimelineEvent evt, DateTime startTime)
        {
            var _ctx = DbCtx.Get();

            var pers = _ctx.Person.FirstOrDefault(p0 => p0.Id == evt.userId);
            var disc = _ctx.Discussion.FirstOrDefault(d0 => d0.Id == evt.discussionId);
            if (disc == null)
            {
                return;
            }
            var topic = _ctx.Topic.FirstOrDefault(t0 => t0.Id == evt.topicId);

            var s = new StatsEvent();
            s.DiscussionId = evt.discussionId;
            s.DiscussionName = disc.Subject;

            s.TopicId = evt.topicId;
            if (topic != null)
                s.TopicName = topic.Name;
            else
                s.TopicName = "";

            s.UserId = evt.userId;
            s.UserName = pers.Name;
            s.Event = (int) evt.e;
            s.Time = startTime.Add(evt.Span);
            s.DeviceType = (int) evt.devType;

            _ctx.AddToStatsEvent(s);
        }
        internal override async Task StartPing()
        {
            _lastPong = DateTime.Now.Add(_pingTimeout);
            _pingInterval = TimeSpan.FromMilliseconds(Math.Max(500, _pingTimeout.TotalMilliseconds / 2));

            while (_connection.IsConnected)
            {
                await Task.Delay(_pingInterval).ConfigureAwait(false);

                try
                {
                    var now = DateTime.Now;

                    if (_lastPong.Add(_pingTimeout) < now)
                    {
                        _connection.Close(WebSocketCloseReasons.GoingAway);
                    }
                    else
                    {
                        ((UInt64)now.Ticks).ToBytes(_pingBuffer.Array, _pingBuffer.Offset);
                        _connection.WriteInternal(_pingBuffer, 8, true, false, WebSocketFrameOption.Ping, WebSocketExtensionFlags.None);
                    }
                }
                catch(Exception ex)
                {
                    DebugLog.Fail("LatencyControlPing.StartPing", ex);
                    _connection.Close(WebSocketCloseReasons.ProtocolError);
                }
            }
        }
 public static DateTime ConvertJavaMiliSecondToDateTime(long javaMS)
 {
     DateTime utcBaseTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
     DateTime dt = utcBaseTime.Add(new TimeSpan(javaMS*
                                                TimeSpan.TicksPerMillisecond)).ToLocalTime();
     return dt;
 }
示例#40
0
    public static System.DateTime ConvertLongToDateTime(long timeStamp)
    {
        System.DateTime dtStart = System.TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
        long            lTime   = long.Parse(timeStamp + "0000000");

        System.TimeSpan toNow = new System.TimeSpan(lTime);
        return(dtStart.Add(toNow));
    }
示例#41
0
    /// <summary>
    /// 时间戳转换成时间
    /// </summary>
    /// <param name="t">时间戳</param>
    /// <returns></returns>
    public static System.DateTime TransToDateTime(uint t)
    {
        System.DateTime dt    = System.TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
        long            lTime = long.Parse(t.ToString() + "0000000");

        System.TimeSpan toNow = new System.TimeSpan(lTime);
        return(dt.Add(toNow));
    }
示例#42
0
 public static System.DateTime Date()
 {
     System.Version  version   = Version();
     System.DateTime startDate = new System.DateTime(2000, 1, 1, 0, 0, 0);
     System.TimeSpan span      = new System.TimeSpan(version.Build, 0, 0, version.Revision * 2);
     System.DateTime buildDate = startDate.Add(span);
     return(buildDate);
 }
示例#43
0
        public static string TimestampToDateTimeString(long timestamp, string format)
        {
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
            TimeSpan        toNow     = new TimeSpan(timestamp * 10000);
            var             dt        = startTime.Add(toNow);

            return(dt.ToString(format));
        }
示例#44
0
        public DateTime ToDateTime(String time)
        {
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
            long            lTime     = long.Parse(time + "0000000");
            TimeSpan        toNow     = new TimeSpan(lTime);

            return(startTime.Add(toNow));
        }
示例#45
0
    private System.DateTime GetTime(string timeStamp)
    {
        System.DateTime dtStart = System.TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
        long            lTime   = long.Parse(timeStamp + "0000000");

        System.TimeSpan toNow = new System.TimeSpan(lTime);
        return(dtStart.Add(toNow));
    }
示例#46
0
 public static void MainDT9()
 {
     System.DateTime today = System.DateTime.Now;
     System.Console.WriteLine("Today = " + System.DateTime.Now);
     System.TimeSpan duration = new System.TimeSpan(40, 0, 0, 0);
     System.DateTime answer   = today.Add(duration);
     System.Console.WriteLine("{0:dddd}", answer);
 }
示例#47
0
        /// <summary>Converts a string-encoded date into a Date object. </summary>
        public static System.DateTime StringToDate(string s)
        {
            long ticks = StringToTime(s) * TimeSpan.TicksPerMillisecond;

            System.DateTime date = new System.DateTime(1970, 1, 1);
            date = date.AddTicks(ticks);
            date = date.Add(TimeZone.CurrentTimeZone.GetUtcOffset(date));
            return(date);
        }
示例#48
0
 IEnumerator StartTime()
 {
     System.TimeSpan oneMinute = System.TimeSpan.FromMinutes(1);
     while (true)
     {
         timeObject = timeObject.Add(oneMinute);
         yield return(new WaitForSeconds(secondLength));
     }
 }
 private void timer2_Tick(object sender, EventArgs e)
 {
     //DisplayA.Text = DateTime.Now.ToString();
     System.DateTime today    = System.DateTime.Now;
     System.TimeSpan duration = new System.TimeSpan(0, -7, 0, 0);
     System.DateTime answer   = today.Add(duration);
     DisplayA.Text = answer.ToString();
     //System.Console.WriteLine("{0:dddd}", answer);
 }
示例#50
0
        /// <summary>
        /// 时间戳转为C#格式时间
        /// </summary>
        /// <param name=”timeStamp”></param>
        /// <returns></returns>
        private DateTime ConvertStringToDateTime(string timeStamp)
        {
            System.DateTime startTime = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Local);

            long     lTime = long.Parse(timeStamp + "0000");
            TimeSpan toNow = new TimeSpan(lTime);

            return(startTime.Add(toNow));
        }
示例#51
0
 public bool Claim(System.Action a)
 {
     if (!Check())
     {
         return(false);
     }
     a();
     Next = Next.Add(Wait);
     return(true);
 }
示例#52
0
 static void Main(string[] args)
 {
     // <Snippet1>
     // Calculate what day of the week is 36 days from this instant.
     System.DateTime today    = System.DateTime.Now;
     System.TimeSpan duration = new System.TimeSpan(36, 0, 0, 0);
     System.DateTime answer   = today.Add(duration);
     System.Console.WriteLine("{0:dddd}", answer);
     // </Snippet1>
 }
示例#53
0
 void Start()
 {
     StartCoroutine("StartTime");
     timeObject = new System.DateTime(1, 1, 1, startHour, 0, 0);
     System.TimeSpan oneDay = System.TimeSpan.FromDays(1);
     endTime          = timeObject.Add(oneDay);
     audioSource      = GetComponent <AudioSource>();
     audioSource.loop = true;
     audioSource.Play();
 }
示例#54
0
 public void FillFreightInfo(FreightReservationOrder freight, DataRow row)
 {
     if (row != null)
     {
         System.TimeSpan?freightDepartureTime = row.ReadNullableUnspecifiedTime("stime");
         FreightPoint    freightPoint         = new FreightPoint();
         FreightPoint    arg_5C_0             = freightPoint;
         System.DateTime dateTime             = row.ReadUnspecifiedDateTime("sdate");
         dateTime          = dateTime.Date;
         arg_5C_0.date     = dateTime.Add(freightDepartureTime ?? System.TimeSpan.FromTicks(0L));
         freightPoint.port = new Airport
         {
             id    = row.ReadInt("sport$inc"),
             alias = row.ReadNullableTrimmedString("sport$alias"),
             name  = row.ReadNullableTrimmedString("sport$name"),
             town  = new Town
             {
                 id   = row.ReadInt("stown$inc"),
                 name = row.ReadNullableString("stown$name")
             }
         };
         freight.departure = freightPoint;
         System.TimeSpan?freightArrivalTime = row.ReadNullableUnspecifiedTime("dtime");
         FreightPoint    freightPoint2      = new FreightPoint();
         FreightPoint    arg_147_0          = freightPoint2;
         dateTime           = freight.departure.date;
         dateTime           = dateTime.Date;
         dateTime           = dateTime.AddDays((double)row.ReadInt("daysinway"));
         arg_147_0.date     = dateTime.Add(freightArrivalTime ?? System.TimeSpan.FromTicks(0L));
         freightPoint2.port = new Airport
         {
             id    = row.ReadInt("dport$inc"),
             alias = row.ReadNullableTrimmedString("dport$alias"),
             name  = row.ReadNullableTrimmedString("dport$name"),
             town  = new Town
             {
                 id   = row.ReadInt("dtown$inc"),
                 name = row.ReadNullableString("dtown$name")
             }
         };
         freight.arrival = freightPoint2;
     }
 }
示例#55
0
 public virtual void reset()
 {
     startTime    = System.DateTime.Now;
     endTime      = startTime.Add(originTimeSpan);
     expire       = false;
     endSig       = false;
     pause        = false;
     pauseTime    = System.DateTime.Now;
     diffTimeSpan = originTimeSpan;
     this.onUpdated();
 }
示例#56
0
    private void SetCookie(HttpResponse res, string name, string value, int day)
    {
        HttpCookie cke = new HttpCookie(name, value);
        //cke.Expires(new DateTime() + 30);
        System.DateTime today = System.DateTime.Now;
        System.TimeSpan duration = new System.TimeSpan(day, 0, 0, 0);
        System.DateTime expiry = today.Add(duration);

        cke.Expires = expiry;
        res.SetCookie(cke);
    }
示例#57
0
        private string GetDateTime(long time) //převod z unix času + časové pásmo pro ČR
        {
            int      TZ   = 2;
            DateTime date = new System.DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(time);

            TimeSpan timee = new TimeSpan(0, TZ, 0, 0);

            DateTime final = date.Add(timee);

            return(final.ToString());
        }
    public void iprintna()
    {
        System.DateTime today    = System.DateTime.Now;
        System.TimeSpan duration = new System.TimeSpan(0, 0, Convert.ToInt32(itmTime), 0);
        System.DateTime result   = today.Add(duration);


        PlayerPrefs.SetString("endTimeshield", result.ToString());

        refreshTime();
    }
示例#59
0
    public virtual int Check(System.DateTime t)
    {
        if ((System.DateTime.Compare(t, TimeLast.Add(Span)) > 0))
        {
            int diff = (int)Mathf.Round(Current_soft + Rate) - Current;
            Set(Current_soft + Rate);

            TimeLast = t;
            return(diff);
        }
        return(0);
    }
示例#60
0
 public static DateTime PauseForMilliSeconds(int MilliSecondsToPauseFor)
 {
     System.DateTime ThisMoment = System.DateTime.Now;
     System.TimeSpan duration   = new System.TimeSpan(0, 0, 0, 0, MilliSecondsToPauseFor);
     System.DateTime AfterWards = ThisMoment.Add(duration);
     while (AfterWards >= ThisMoment)
     {
         System.Windows.Forms.Application.DoEvents();
         ThisMoment = System.DateTime.Now;
     }
     return(System.DateTime.Now);
 }