/// <param name="when">
		/// <see cref="System.DateTime">System.DateTime</see>
		/// to format
		/// </param>
		/// <returns>
		/// age of given
		/// <see cref="System.DateTime">System.DateTime</see>
		/// compared to now formatted in the same
		/// relative format as returned by
		/// <code>git log --relative-date</code>
		/// </returns>
		public static string Format(DateTime when)
		{
			long ageMillis = (Runtime.CurrentTimeMillis() - when.GetTime());
			// shouldn't happen in a perfect world
			if (ageMillis < 0)
			{
				return JGitText.Get().inTheFuture;
			}
			// seconds
			if (ageMillis < UpperLimit(MINUTE_IN_MILLIS))
			{
				return MessageFormat.Format(JGitText.Get().secondsAgo, Round(ageMillis, SECOND_IN_MILLIS
					));
			}
			// minutes
			if (ageMillis < UpperLimit(HOUR_IN_MILLIS))
			{
				return MessageFormat.Format(JGitText.Get().minutesAgo, Round(ageMillis, MINUTE_IN_MILLIS
					));
			}
			// hours
			if (ageMillis < UpperLimit(DAY_IN_MILLIS))
			{
				return MessageFormat.Format(JGitText.Get().hoursAgo, Round(ageMillis, HOUR_IN_MILLIS
					));
			}
			// up to 14 days use days
			if (ageMillis < 14 * DAY_IN_MILLIS)
			{
				return MessageFormat.Format(JGitText.Get().daysAgo, Round(ageMillis, DAY_IN_MILLIS
					));
			}
			// up to 10 weeks use weeks
			if (ageMillis < 10 * WEEK_IN_MILLIS)
			{
				return MessageFormat.Format(JGitText.Get().weeksAgo, Round(ageMillis, WEEK_IN_MILLIS
					));
			}
			// months
			if (ageMillis < YEAR_IN_MILLIS)
			{
				return MessageFormat.Format(JGitText.Get().monthsAgo, Round(ageMillis, MONTH_IN_MILLIS
					));
			}
			// up to 5 years use "year, months" rounded to months
			if (ageMillis < 5 * YEAR_IN_MILLIS)
			{
				long years = ageMillis / YEAR_IN_MILLIS;
				string yearLabel = (years > 1) ? JGitText.Get().years : JGitText.Get().year;
				//
				long months = Round(ageMillis % YEAR_IN_MILLIS, MONTH_IN_MILLIS);
				string monthLabel = (months > 1) ? JGitText.Get().months : JGitText.Get().month;
				//
				return MessageFormat.Format(JGitText.Get().yearsMonthsAgo, new object[] { years, 
					yearLabel, months, monthLabel });
			}
			// years
			return MessageFormat.Format(JGitText.Get().yearsAgo, Round(ageMillis, YEAR_IN_MILLIS
				));
		}
Example #2
0
		/// <summary>Construct a PersonIdent from simple data</summary>
		/// <param name="aName"></param>
		/// <param name="aEmailAddress"></param>
		/// <param name="aWhen">local time stamp</param>
		/// <param name="aTZ">time zone</param>
		public PersonIdent(string aName, string aEmailAddress, DateTime aWhen, TimeZoneInfo
			 aTZ)
		{
			name = aName;
			emailAddress = aEmailAddress;
			when = aWhen.GetTime();
			tzOffset = aTZ.GetOffset(when) / (60 * 1000);
		}
Example #3
0
		/// <summary>
		/// Copy a
		/// <see cref="PersonIdent">PersonIdent</see>
		/// , but alter the clone's time stamp
		/// </summary>
		/// <param name="pi">
		/// original
		/// <see cref="PersonIdent">PersonIdent</see>
		/// </param>
		/// <param name="aWhen">local time</param>
		public PersonIdent(NGit.PersonIdent pi, DateTime aWhen)
		{
			name = pi.GetName();
			emailAddress = pi.GetEmailAddress();
			when = aWhen.GetTime();
			tzOffset = pi.tzOffset;
		}
Example #4
0
		/// <summary>Create a new filter to select commits after a given date/time.</summary>
		/// <remarks>Create a new filter to select commits after a given date/time.</remarks>
		/// <param name="ts">the point in time to cut on.</param>
		/// <returns>a new filter to select commits on or after <code>ts</code>.</returns>
		public static RevFilter After(DateTime ts)
		{
			return After(ts.GetTime());
		}
Example #5
0
		/// <summary>Create a new filter to select commits before a given date/time.</summary>
		/// <remarks>Create a new filter to select commits before a given date/time.</remarks>
		/// <param name="ts">the point in time to cut on.</param>
		/// <returns>a new filter to select commits on or before <code>ts</code>.</returns>
		public static RevFilter Before(DateTime ts)
		{
			return Before(ts.GetTime());
		}
Example #6
0
		/// <summary>
		/// Create a new filter to select commits after or equal a given date/time <code>since</code>
		/// and before or equal a given date/time <code>until</code>.
		/// </summary>
		/// <remarks>
		/// Create a new filter to select commits after or equal a given date/time <code>since</code>
		/// and before or equal a given date/time <code>until</code>.
		/// </remarks>
		/// <param name="since">the point in time to cut on.</param>
		/// <param name="until">the point in time to cut off.</param>
		/// <returns>a new filter to select commits between the given date/times.</returns>
		public static RevFilter Between(DateTime since, DateTime until)
		{
			return Between(since.GetTime(), until.GetTime());
		}
Example #7
0
			internal virtual void Finish()
			{
				DateTime end = new DateTime();
				long elapsedMs = end.GetTime() - start.GetTime();
				Set(html, "results.testlist", Join(arguments.GetTestList()));
				Set(html, "results.skiplist", Join(arguments.GetSkipList()));
				string pct = new DecimalFormat("##0.00").Format((double)failures / (double)tests * 100.0);
				Set(html, "results.results", "Tests attempted: " + tests + " Failures: " + failures + " (" + pct + "%)");
				Set(html, "results.platform", "java.home=" + Runtime.GetProperty("java.home") + "\n" + "java.version=" + Runtime.GetProperty("java.version") + "\n" + "os.name=" + Runtime.GetProperty("os.name"));
				Set(html, "results.classpath", Runtime.GetProperty("java.class.path").Replace(FilePath.pathSeparatorChar, ' '));
				int elapsedSeconds = (int)(elapsedMs / 1000);
				int elapsedMinutes = elapsedSeconds / 60;
				elapsedSeconds = elapsedSeconds % 60;
				string elapsed = string.Empty + elapsedMinutes + " minutes, " + elapsedSeconds + " seconds";
				Set(html, "results.elapsed", elapsed);
				Set(html, "results.time", new SimpleDateFormat("MMMM d yyyy h:mm:ss aa").Format(new DateTime()));
				Write(html, false);
				Write(xml, true);
			}
Example #8
0
			private void Finish()
			{
				DateTime end = new DateTime();
				long elapsed = end.GetTime() - start.GetTime();
				this.target.SetAttribute("elapsed", elapsed.ToString());
			}
Example #9
0
		/// <summary>Construct a PersonIdent from simple data</summary>
		/// <param name="aName"></param>
		/// <param name="aEmailAddress"></param>
		/// <param name="aWhen">local time stamp</param>
		/// <param name="aTZ">time zone</param>
		public PersonIdent(string aName, string aEmailAddress, DateTime aWhen, TimeZoneInfo
			 aTZ) : this(aName, aEmailAddress, aWhen.GetTime(), aTZ.GetOffset(aWhen.GetTime(
			)) / (60 * 1000))
		{
		}
Example #10
0
		/// <summary>
		/// Copy a
		/// <see cref="PersonIdent">PersonIdent</see>
		/// , but alter the clone's time stamp
		/// </summary>
		/// <param name="pi">
		/// original
		/// <see cref="PersonIdent">PersonIdent</see>
		/// </param>
		/// <param name="aWhen">local time</param>
		public PersonIdent(NGit.PersonIdent pi, DateTime aWhen) : this(pi.GetName(), pi.GetEmailAddress
			(), aWhen.GetTime(), pi.tzOffset)
		{
		}
Example #11
0
 public void GetTimeWorks()
 {
     var dt = new DateTime(DateTime.Utc(1970, 1, 2));
     Assert.AreEqual(dt.GetTime(), 1440 * 60 * 1000);
 }
        private void flushQueue()
        {
            var ind = 0;

            for (ind = 0; answerQueue.Count > 0 && ind < QUEUEPERTICK; ind++)
            {
                ServerLogger.LogDebug(string.Format("-- answer pop, queue length: {0}", answerQueue.Count), null);


                var answer = answerQueue[0];
                answerQueue.RemoveAt(0);

                var room = getRoomByPlayer(answer.Item1.UserName);
                if (room == null)
                {
                    ServerLogger.LogError("Room not found for user: " + answer.Item1.UserName, answer);

                    continue;
                    throw new Exception("idk");
                }

                var dict = new CardGameAnswer();
                dict.Value = answer.Item2.Answer;
                room.EmulatedAnswers.Add(dict);
                var answ = room.Fiber.Run<DebugFiberYieldResponse>(dict);

                //dataManager.GameData.Insert(new GameInfoModel() {GameName = room.Name, AnswerIndex = answ.Contents});
                processGameResponse(room, answ);
            }

            if (ind == 0)
                skipped__++;
            else
            {
                total__ += ind;
                if ((total__ + skipped__) % 20 == 0)
                {
                    var dt = new DateTime();
                    ServerLogger.LogDebug(string.Format("{0} =  tot: __{1}__ + shift: {2} + T: {3} + QSize: {4} + T Rooms: {5} + Per SecondL {6}",
                                             myServerManager.DebugGameServerIndex.Substring(0, 19),
                                             (total__ + skipped__),
                                             ind,
                                             total__,
                                             answerQueue.Count,
                                             rooms.Count,
                                             (gameData.TotalQuestionsAnswered / ((dt.GetTime() - startTime.GetTime()) / 1000d))),
                               null);
                }
            }
        }
Example #13
0
		public static int Enc_time(DateTime date, byte[] dst, int di, int enc)
		{
			long t;
			switch (enc)
			{
				case Time1970Sec32Be:
				{
					return Enc_uint32be((int)(date.GetTime() / 1000L), dst, di);
				}

				case Time1970Sec32Le:
				{
					return Enc_uint32le((int)(date.GetTime() / 1000L), dst, di);
				}

				case Time1904Sec32Be:
				{
					return Enc_uint32be((int)((date.GetTime() / 1000L + SecBetweeen1904And1970) &
						 unchecked((int)(0xFFFFFFFF))), dst, di);
				}

				case Time1904Sec32Le:
				{
					return Enc_uint32le((int)((date.GetTime() / 1000L + SecBetweeen1904And1970) &
						 unchecked((int)(0xFFFFFFFF))), dst, di);
				}

				case Time1601Nanos64Be:
				{
					t = (date.GetTime() + MillisecondsBetween1970And1601) * 10000L;
					return Enc_uint64be(t, dst, di);
				}

				case Time1601Nanos64Le:
				{
					t = (date.GetTime() + MillisecondsBetween1970And1601) * 10000L;
					return Enc_uint64le(t, dst, di);
				}

				case Time1970Millis64Be:
				{
					return Enc_uint64be(date.GetTime(), dst, di);
				}

				case Time1970Millis64Le:
				{
					return Enc_uint64le(date.GetTime(), dst, di);
				}

				default:
				{
					throw new ArgumentException("Unsupported time encoding");
				}
			}
		}