public void testGetInstance() { Console.WriteLine("getInstance"); TimeFormatter result = TimeFormatter.getInstance(); Assert.IsNotNull(result); }
public void TestParseTimestamp() { Assert.Equal(0L, CatapultCsvImporter.ConvHmssToEpochUs("0:00.00")); Assert.Equal(TimeFormatter.TimeFromTimeSpan(TimeSpan.FromMilliseconds(2290)), CatapultCsvImporter.ConvHmssToEpochUs("0:02.29")); Assert.Equal(TimeFormatter.TimeFromTimeSpan(new TimeSpan(0, 0, 51, 50, 0)), CatapultCsvImporter.ConvHmssToEpochUs("51:50.00")); Assert.Equal(TimeFormatter.TimeFromTimeSpan(new TimeSpan(0, 1, 9, 11, 0)), CatapultCsvImporter.ConvHmssToEpochUs("1:09:11.00")); }
public static UsersViewModel MToVM(User user) { var temp = new UsersViewModel() { ID = user.ID, Code = Comparison.IsNullOrEmpty(user.Code) ? "" : user.Code, LastName = Comparison.IsNullOrEmpty(user.LastName) ? "" : user.LastName, MiddleName = Comparison.IsNullOrEmpty(user.MiddleName) ? "" : user.MiddleName, FirstName = Comparison.IsNullOrEmpty(user.FirstName) ? "" : user.FirstName, ExtensionName = Comparison.IsNullOrEmpty(user.ExtensionName) ? "" : user.ExtensionName, Gender = Comparison.IsNullOrEmpty(user.Gender) ? "N/A" : user.Gender, MaritalStatus = Comparison.IsNullOrEmpty(user.MaritalStatus) ? "N/A" : user.MaritalStatus, Nationality = Comparison.IsNullOrEmpty(user.Nationality) ? "N/A" : user.Nationality, Religion = Comparison.IsNullOrEmpty(user.Religion) ? "N/A" : user.Religion, Address = Comparison.IsNullOrEmpty(user.Address) ? "N/A" : user.Address, Birthday = TimeFormatter.DateToString(user.Birthday.Value), Jobtitle = JobTitleUtility.MToVM(user.JobTitle), Email = Comparison.IsNullOrEmpty(user.Email) ? "N/A" : user.Email, ContactPerson = Comparison.IsNullOrEmpty(user.ContactPerson) ? "N/A" : user.ContactPerson, ContactNumber = Comparison.IsNullOrEmpty(user.ContactNumber) ? "N/A" : user.ContactNumber, profileImage = Comparison.IsNullOrEmpty(user.ProfileImage) ? "/Assets/images/no-image.jpg" : user.ProfileImage, Company = CompanyUtility.MToVM(user.Company), aspNetUser = MToVM(user.AspNetUser), Department = DataVerification.IsNull(user.Department) ? new DepartmentViewModel() { Name = "N/A" } : DepartmentUtility.MToVM(user.Department), JobStatus = JobStatusUtility.MToVM(user.JobStatu), User = AspNetUserUtility.MToVM(user.AspNetUser), TimeZone = user.TimeZone }; return(temp); }
private void initTimes() { // set times showed in GUI startTime = TimeFormatter.HoursMinutesSecondsToDouble(18, 0, 0); hockeyMatchTime = startTime + TimeFormatter.HoursMinutesSecondsToDouble(2, 0, 0); endTime = hockeyMatchTime + TimeFormatter.HoursMinutesSecondsToDouble(1, 0, 0); }
public void TimeFormattingTest() { var oneSecond = microsPerSec; Assert.Equal("00:00:01.000", TimeFormatter.FormatTime(oneSecond)); var oneMinute = 60L * oneSecond; Assert.Equal("00:01:00.000", TimeFormatter.FormatTime(oneMinute)); var oneHour = 60L * oneMinute; Assert.Equal("01:00:00.000", TimeFormatter.FormatTime(oneHour)); var oneHourOneMinuteOneSecond = oneHour + oneMinute + oneSecond; Assert.Equal("01:01:01.000", TimeFormatter.FormatTime(oneHourOneMinuteOneSecond)); Assert.Equal("00:00:00.100", TimeFormatter.FormatTime(100000)); Assert.Equal("00:00:00.111", TimeFormatter.FormatTime(111000)); Assert.Equal("00:00:00.000", TimeFormatter.FormatTime(000100)); var testDate = TimeFormatter.TimeFromDateTime(new DateTime(2010, 10, 20, 8, 13, 37, 125)); Assert.Equal("2010-10-20\n08:13:37.125", TimeFormatter.FormatTime(testDate)); Assert.Equal("-01:01:01.000", TimeFormatter.FormatTime(-oneHourOneMinuteOneSecond)); }
public void DifferentDayWithoutTimeTest() { DateTime start = new DateTime(2013, 12, 15); DateTime end = new DateTime(2013, 12, 16); TimeSpan duration = new TimeSpan(3, 4, 5); TimeFormatter formatter = new TimeFormatter(); string interval = formatter.GetInterval( start, end, IntervalEdge.Open, IntervalEdge.Open, duration); string expectedInterval = string.Concat( "(", formatter.GetShortDate(start), formatter.StartEndSeparator, formatter.GetShortDate(end), ")", formatter.DurationSeparator, formatter.GetDuration(duration)); Assert.Equal(interval, expectedInterval); } // DifferentDayWithoutTimeTest
private void Grid_SplitSettings_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.RowIndex < splitToEventList.Count) { if (e.ColumnIndex == COLUMNINDEX_SEGMENTNAME) { e.Value = splitToEventList[e.RowIndex].SegmentName; } else if (e.ColumnIndex == COLUMNINDEX_EVENT) { e.Value = SplitsToEvents.GetEnumDescription(splitToEventList[e.RowIndex].EventType); } else if (e.ColumnIndex == COLUMNINDEX_DELAY) { var comparisonValue = splitToEventList[e.RowIndex].Delay; e.Value = TimeFormatter.Format(TimeSpan.FromSeconds(comparisonValue)); e.FormattingApplied = true; } else if (e.ColumnIndex == COLUMNINDEX_ACTION) { bool eventUsed = splitToEventList[e.RowIndex].Action.isUsed && splitToEventList[e.RowIndex].EventType == SplitEventType.StartPredictionOnSplitStart; e.Value = eventUsed ? "!" : ""; e.CellStyle.BackColor = eventUsed ? Color.Red : Color.Transparent; } } }
protected override void GetDisplayContent(ChannelLink link, out List <Tuple <string, DiscordEmbed> > tagAndContent) { tagAndContent = new List <Tuple <string, DiscordEmbed> >(); DiscordEmbedBuilder builder = new DiscordEmbedBuilder(); builder.WithColor(MessageBuilder.EmbedColor); foreach (Election election in ElectionManager.Obj.CurrentElections.Where(x => x.Valid() && x.State == Shared.Items.ProposableState.Active)) { string tag = BaseTag + " [" + election.Id + "]"; builder.WithTitle(election.Name); // Proposer name builder.AddField("Proposer", election.Creator.Name); // Time left builder.AddField("Time Left", TimeFormatter.FormatSpan(election.TimeLeft)); // Process builder.AddField("Process", election.Process.Name); // Choices if (!election.BooleanElection && election.Choices.Count > 0) { string choiceDesc = string.Empty; foreach (ElectionChoice choice in election.Choices) { choiceDesc += choice.Name + "\n"; } builder.AddField("Choices", choiceDesc); } // Votes string voteDesc = string.Empty; foreach (RunoffVote vote in election.Votes) { string topChoiceName = null; int topChoiceID = vote.RankedVotes.FirstOrDefault(); foreach (ElectionChoice choice in election.Choices) { if (choice.ID == topChoiceID) { topChoiceName = choice.Name; break; } } voteDesc += vote.Voter.Name + ": " + topChoiceName + "\n"; } if (string.IsNullOrEmpty(voteDesc)) { voteDesc = "--- No Votes Recorded ---"; } builder.AddField("Votes (" + election.TotalVotes + ")", voteDesc); if (builder.Fields.Count > 0) { tagAndContent.Add(new Tuple <string, DiscordEmbed>(tag, builder.Build())); } builder.ClearFields(); } }
public void WhenTimeFormatterCallenThenSplitIntoHourMinutAmPm() { TimeFormatter timeFormatter = new TimeFormatter(TimeList); Assert.True(timeFormatter.IsTimeFormatted); Console.WriteLine("WhenTimeFormatterCallenThenSplitIntoHourMinutAmPm Done!"); }
public override void Draw(SectionModule section) { if (RendezvousProcessor.ShowDetails) { this.DrawLine(TimeFormatter.ConvertToString(RendezvousProcessor.TimeToRendezvous), section.IsHud); } }
public ActionResult GetPubicInformationByType(int page, int limit, int type) { var dataObj = PublicInformationService.GetEntities(u => u.DelFlag == 1 && u.Type == type); var data = dataObj .OrderByDescending(x => x.SubTime) .Take(limit * page).Skip(limit * (page - 1)).ToList();//进行分页 var result = new List <PublicInformationDTO>(); foreach (var item in data) { var info = new PublicInformationDTO { Id = item.Id, Title = item.Title, Content = Server.HtmlDecode(item.Content), SubTime = TimeFormatter.TimeFormat(item.SubTime.ToString()), SubUnit = item.SubUnit, Author = item.Author, BrowseTime = item.BrowseTime ?? 0, Remark = item.Remark, Type = GetInfoType(item.Type ?? 0) }; result.Add(info); } var jsondata = new { msg = string.Empty, code = Status.success, count = dataObj.Count(), data = result }; return(Json(jsondata, JsonRequestBehavior.AllowGet)); }
public ActionResult GetPubicInformationById(int Id) { var info = new PublicInformationDTO(); var dataObjs = PublicInformationService.GetEntities(u => u.Id == Id && u.DelFlag == 1); if (dataObjs != null && dataObjs.Count() > 0) { var dataObj = dataObjs.FirstOrDefault(); info.Id = dataObj.Id; info.Title = dataObj.Title; info.Content = Server.HtmlDecode(dataObj.Content); info.SubTime = TimeFormatter.TimeFormat(dataObj.SubTime.ToString()); info.SubUnit = dataObj.SubUnit; info.Author = dataObj.Author; info.BrowseTime = dataObj.BrowseTime ?? 0; info.Remark = dataObj.Remark; info.Type = GetInfoType(dataObj.Type ?? 0); var jsondata = new { code = Status.success, count = 1, data = info }; return(Json(jsondata, JsonRequestBehavior.AllowGet)); } else { return(Json(new { code = Status.error, count = 0, data = info }, JsonRequestBehavior.AllowGet)); } }
private void OnTimerChanged(TimerChangedMessage message) { if (message.TimerIsRunning) { TextColor = GreenYellowRedSelector.GetBrushForTimeRemaining(message.RemainingSecs); TimeString = TimeFormatter.FormatTimerDisplayString(message.CountUp ? message.ElapsedSecs : message.RemainingSecs); // if duration of talk is greater than 1hr we only start showing the sector // when remaining time is less than 1 hr (for sake of clarity)... InitOverallDurationSector(message.RemainingSecs); if (DurationSector != null) { DateTime now = DateTime.Now; var currentAngle = CalcAngleFromTime(now); if (Math.Abs(currentAngle - DurationSector.CurrentAngle) > 0.15) // prevent gratuitous updates { var d = DurationSector.Clone(); d.CurrentAngle = currentAngle; d.IsOvertime = message.RemainingSecs < 0; DurationSector = d; } } } }
private void AddRequests(IEnumerable <Users> newRequests) { ListOutStandingReq = new ObservableCollection <AddRequest>(); ResReqCount = 0; foreach (var user in newRequests) { if (user.HasResponded) { ResReqCount++; TimeFormatter TimeTimer = new TimeFormatter(user.ReqTime); SendReq(new AddRequest(user.ReqTo, user.HasResponded, TimeTimer.reqTime)); } } foreach (var user in newRequests) { if (!user.HasResponded) { TimeFormatter TimeTimer = new TimeFormatter(user.ReqTime); SendReq(new AddRequest(user.ReqTo, user.HasResponded, TimeTimer.reqTime)); } } RaisePropertyChanged(() => ListOutStandingReq); }
public override void Draw(Unity.Flight.ISectionModule section) { if (RendezvousProcessor.ShowDetails) { this.DrawLine(TimeFormatter.ConvertToString(RendezvousProcessor.OrbitalPeriod, "F3"), section.IsHud); } }
public override void Draw(SectionModule section) { if (ImpactProcessor.ShowDetails) { this.DrawLine(TimeFormatter.ConvertToString(ImpactProcessor.Time), section.IsHud); } }
public override void Draw() { // may be the luck with drawing on two windows parallel-ly ran out... bool isHost = _role == MultiplayerRole.Host; MultiplayerData data = _connection.CurrentData; PlayerData host = isHost ? data.Host : data.Guest, guest = isHost ? data.Guest : data.Host; // draw player side InformationBar.Draw( TimeFormatter.GetTime(_connection.TimePlayed), (host.Board as MinesweeperBoard).Flag, _playerProps.WindowWidth ); DrawBoard(host.Board.DrawableBoard); // a line in between screens int wW = _playerProps.WindowWidth, wH = _playerProps.WindowHeight; SplashKit.DrawLine(Constants.TEXT_COLOR, wW, 0, wW, wH); // draw opponent side InformationBar.Draw( TimeFormatter.GetTime(guest.Time), guest.Flag, _opponentProps.WindowWidth, true, _playerProps.WindowWidth ); DrawBoard(guest.Board.DrawableBoard, true); }
public static string FormatLarge(Seed seed) { return($"Вкус: {seed.Taste}\n\n" + $"Габитус: {seed.Gabitus}\n\n" + $"Время роста: {TimeFormatter.Format(seed.GrowTime)}\n\n" + $"Цена: {seed.Price}<sprite name=\"Money\">\n"); }
public static UserAttendanceVM MToVM(Attendance item) { var temp = new UserAttendanceVM() { id = item.ID, profileImage = item.User.ProfileImage == null ? "/Assets/images/no-image.jpg" : item.User.ProfileImage, name = item.User.FirstName + " " + item.User.LastName + " " + item.User.ExtensionName, actualLoginImage = item.TimeInImage == null ? "/Assets/images/no-image.jpg" : item.TimeInImage, actualLoginTime = item.TimeIn.HasValue ? item.TimeIn.Value.Hours + ":" + item.TimeIn.Value.Minutes : "not yet", actualLogoutImage = item.TimeOutImage == null ? "/Assets/images/no-image.jpg" : item.TimeOutImage, actualLogoutTime = item.TimeOut != null ? item.TimeOut.Value.Hours + ":" + item.TimeOut.Value.Minutes : "not yet", TotalWorkHours = item.HrsWork.HasValue ? item.HrsWork.Value.ToString() : "N/A", TotalBreakTime = item.TotalBreakTime.HasValue ? item.TotalBreakTime.Value.ToString() : "N/A", ProductiveHours = item.ProductiveHrs.HasValue ? item.ProductiveHrs.Value.ToString() : "N/A", Remarks = item.Remarks == "" || item.Remarks == null ? "N/A" : item.Remarks, DateCreated = TimeFormatter.DateToString(item.CreatedAt.Value), AttendanceDate = TimeFormatter.DateToString(item.AttendanceDate.Value), User = new UsersViewModel() { ID = item.User.ID, FirstName = item.User.FirstName, LastName = item.User.LastName, MiddleName = item.User.MiddleName, ExtensionName = item.User.ExtensionName }, Shift = new ShiftViewModel() { ID = item.ShiftID, TimeIn = item.Shift.TimeIn.HasValue ? item.Shift.TimeIn.Value.ToString() : "00:00:00", TimeOut = item.Shift.TimeOut.HasValue ? item.Shift.TimeOut.Value.ToString() : "00:00:00" }, Status = new AttendanceStatusViewModel() { ID = item.AttendanceStatusID } }; return(temp); }
protected void DayPilotBubble1_RenderEventBubble(object sender, RenderEventBubbleEventArgs e) { e.InnerHTML = string.Format("<b>{0}</b><br />Start: {1} <br/>End: {2}<br/>Event description.", e.Text, TimeFormatter.GetHourMinutes(e.Start, DayPilotCalendar1.TimeFormat), TimeFormatter.GetHourMinutes(e.End, DayPilotCalendar1.TimeFormat)); }
public void CreateTimeFormatterCtor_WithLegalLanguage() { TimeFormatter tf = null; Assert.DoesNotThrow(() => tf = new TimeFormatter()); Assert.AreEqual("en", tf.DefaultTwoLetterISOLanguageName); }
public void SameDayTest() { DateTime start = new DateTime(2013, 12, 15, 17, 34, 54, 900); DateTime end = new DateTime(2013, 12, 15, 17, 35, 0, 0); TimeSpan duration = new TimeSpan(3, 4, 5); TimeFormatter formatter = new TimeFormatter(); string interval = formatter.GetInterval( start, end, IntervalEdge.Open, IntervalEdge.Open, duration); string expectedInterval = string.Concat( "(", formatter.GetDateTime(start), formatter.StartEndSeparator, formatter.GetLongTime(end), ")", formatter.DurationSeparator, formatter.GetDuration(duration)); Assert.Equal(interval, expectedInterval); } // SameDayTest
public override void Draw(Unity.Flight.ISectionModule section) { if (RendezvousProcessor.ShowDetails) { this.DrawLine(TimeFormatter.ConvertToString(RendezvousProcessor.TimeToTransferAngle), section.IsHud); } }
private ToolTip BuildTestToolTip(string text) { return(new ToolTip { Content = text + entry.TestType + " test.\nExecution Time:\t" + TimeFormatter.FormatTime(entry.AverageTimeUnder), Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom, }); }
private string sumOfBestComponent() { var comparison = State.CurrentComparison; var method = State.CurrentTimingMethod; var sob = SumOfBest.CalculateSumOfBest(State.Run, State.Settings.SimpleSumOfBest, true, State.CurrentTimingMethod); return(formatInfoText("Sum of Best", TimeFormatter.Format(sob)) + "\n"); }
public void Test_Elapsed_Zero_Minutes() { var timeformatter = new TimeFormatter(); var actual = timeformatter.elapsedMinutes(DateTime.Now); var expected = "0"; Assert.AreEqual(actual, expected); }
public void DefaultFormatOptions_Can_Be_Set() { var formatter = new TimeFormatter { DefaultFormatOptions = TimeSpanFormatOptions.RangeDays }; Assert.That(formatter.DefaultFormatOptions, Is.EqualTo(TimeSpanFormatOptions.RangeDays)); }
public RunTimeStatistic() { ValueFunc = () => { var timeSpan = GetTimeSpan(); return(timeSpan == null ? null : TimeFormatter.Format(timeSpan.Value)); }; }
[Test]//, ExpectedException(typeof(BadlyFormedTime))] public void testFormat_BAD_PM() { Console.WriteLine("format"); String input = "13:25AM"; TimeFormatter instance = new TimeFormatter(); Assert.Throws <BadlyFormedTime>(() => instance._format(input)); }
public async void SimpleDecoding() { var decoder = GetDecoder(); var videoLength = await decoder.GetLengthAsync(); //This video should be about 5 seconds long Assert.InRange(videoLength, TimeFormatter.TimeFromSeconds(4), TimeFormatter.TimeFromSeconds(6)); }