当前位置: 首页>>代码示例>>C#>>正文


C# TimeSpan.ToStringHmm方法代码示例

本文整理汇总了C#中System.TimeSpan.ToStringHmm方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSpan.ToStringHmm方法的具体用法?C# TimeSpan.ToStringHmm怎么用?C# TimeSpan.ToStringHmm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.TimeSpan的用法示例。


在下文中一共展示了TimeSpan.ToStringHmm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FillMain


//.........这里部分代码省略.........
             oneAdj=TimeSpan.Zero;
             if(clock.AdjustIsOverridden) {
                 oneAdj+=clock.Adjust;
             }
             else {
                 oneAdj+=clock.AdjustAuto;//typically zero
             }
             daySpan+=oneAdj;
             weekSpan+=oneAdj;
             periodSpan+=oneAdj;
             row.Cells.Add(ClockEvents.Format(oneAdj));
             //Overtime------------------------------
             oneOT=TimeSpan.Zero;
             if(clock.OTimeHours!=TimeSpan.FromHours(-1)) {//overridden
                 oneOT=clock.OTimeHours;
             }
             else {
                 oneOT=clock.OTimeAuto;//typically zero
             }
             otspan+=oneOT;
             daySpan-=oneOT;
             weekSpan-=oneOT;
             periodSpan-=oneOT;
             row.Cells.Add(ClockEvents.Format(oneOT));
             //Daily-----------------------------------
             //if this is the last entry for a given date
             if(i==mergedAL.Count-1//if this is the last row
                 || GetDateForRow(i+1) != curDate)//or the next row is a different date
             {
                 if(IsBreaks){
                     if(clock.TimeDisplayed2.Year<1880){//if they have not clocked back in yet from break
                         //display the timespan of oneSpan using current time as the other number.
                         oneSpan=DateTime.Now-clock.TimeDisplayed1+TimeDelta;
                         row.Cells.Add(oneSpan.ToStringHmmss());
                         daySpan+=oneSpan;
                     }
                     else{
                         row.Cells.Add(ClockEvents.Format(daySpan));
                     }
                 }
                 else{
                     row.Cells.Add(ClockEvents.Format(daySpan));
                 }
                 daySpan=new TimeSpan(0);
             }
             else{//not the last entry for the day
                 row.Cells.Add("");
             }
             //Weekly-------------------------------------
             WeeklyTotals[i]=weekSpan;
             if(IsBreaks){
                 row.Cells.Add("");
             }
             //if this is the last entry for a given week
             else if(i==mergedAL.Count-1//if this is the last row
                 || cal.GetWeekOfYear(GetDateForRow(i+1),rule,DayOfWeek.Sunday)//or the next row has a
                 != cal.GetWeekOfYear(clock.TimeDisplayed1.Date,rule,DayOfWeek.Sunday))//different week of year
             {
                 row.Cells.Add(ClockEvents.Format(weekSpan));
                 weekSpan=new TimeSpan(0);
             }
             else {
                 //row.Cells.Add(ClockEvents.Format(weekSpan));
                 row.Cells.Add("");
             }
             //Note-----------------------------------------
开发者ID:nampn,项目名称:ODental,代码行数:67,代码来源:FormTimeCard.cs

示例2: FillCustomerTab


//.........这里部分代码省略.........
				if(firstProc!=null) {
					startDate=firstProc.ProcDate;
				}
				DateTime month0=DateTime.Now;
				DateTime month1=DateTime.Now.AddMonths(-1);
				DateTime month2=DateTime.Now.AddMonths(-2);
				DateTime month3=DateTime.Now.AddMonths(-3);
				//Set the month labels.
				labelMonth0.Text=CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(month0.Month);
				labelMonth1.Text=CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(month1.Month);
				labelMonth2.Text=CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(month2.Month);
				labelMonth3.Text=CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(month3.Month);
				List<Commlog>	commlogsList=Commlogs.GetTimedCommlogsForPat(PatCur.Guarantor);
				TimeSpan month0Span=new TimeSpan();
				TimeSpan month1Span=new TimeSpan();
				TimeSpan month2Span=new TimeSpan();
				TimeSpan month3Span=new TimeSpan();
				TimeSpan totalSpan=new TimeSpan();
				int avgCount=0;
				bool addToAvg=true;
				//Add up the length of time each call took within the corresponding month.
				for(int i=0;i<commlogsList.Count;i++) {
					DateTime tempDateTime=commlogsList[i].CommDateTime;
					DateTime tempTimeEnd=commlogsList[i].DateTimeEnd;
					TimeSpan tempSpan=tempTimeEnd-tempDateTime;
					if(tempDateTime.Year==month0.Year && tempDateTime.Month==month0.Month) {
						month0Span=month0Span.Add(tempSpan);
						addToAvg=false;//Avg should not include this months numbers.
					}
					else if(tempDateTime.Year==month1.Year && tempDateTime.Month==month1.Month) {
						month1Span=month1Span.Add(tempSpan);
					}
					else if(tempDateTime.Year==month2.Year && tempDateTime.Month==month2.Month) {
						month2Span=month2Span.Add(tempSpan);
					}
					else if(tempDateTime.Year==month3.Year && tempDateTime.Month==month3.Month) {
						month3Span=month3Span.Add(tempSpan);
					}
					//Take current commlog and see if its greater than or equal to two months after first completed proc date.
					if(new DateTime(tempDateTime.Year,tempDateTime.Month,1)>=new DateTime(startDate.AddMonths(2).Year,startDate.AddMonths(2).Month,1)
						&& addToAvg) {
						totalSpan=totalSpan.Add(tempSpan);
						avgCount++;
					}
					addToAvg=true;
				}
				if(month0Span.Hours>=3) {
					textMonth0.BackColor=Color.Red;
					textMonth0.ForeColor=Color.White;
					textMonth0.Font=new Font(textMonth1.Font,FontStyle.Bold);
				}
				else {
					textMonth0.ForeColor=Color.Black;
					textMonth0.BackColor=SystemColors.Control;
					textMonth0.Font=new Font(textMonth1.Font,FontStyle.Regular);
				}
				if(month1Span.Hours>=3) {
					textMonth1.BackColor=Color.Red;
					textMonth1.ForeColor=Color.White;
					textMonth1.Font=new Font(textMonth1.Font,FontStyle.Bold);
				}
				else {
					textMonth1.ForeColor=Color.Black;
					textMonth1.BackColor=SystemColors.Control;
					textMonth1.Font=new Font(textMonth1.Font,FontStyle.Regular);
				}
				if(month2Span.Hours>=3) {
					textMonth2.BackColor=Color.Red;
					textMonth2.ForeColor=Color.White;
					textMonth2.Font=new Font(textMonth2.Font,FontStyle.Bold);
				}
				else {
					textMonth2.ForeColor=Color.Black;
					textMonth2.BackColor=SystemColors.Control;
					textMonth2.Font=new Font(textMonth2.Font,FontStyle.Regular);
				}
				if(month3Span.Hours>=3) {
					textMonth3.BackColor=Color.Red;
					textMonth3.ForeColor=Color.White;
					textMonth3.Font=new Font(textMonth3.Font,FontStyle.Bold);
				}
				else {
					textMonth3.ForeColor=Color.Black;
					textMonth3.BackColor=SystemColors.Control;
					textMonth3.Font=new Font(textMonth3.Font,FontStyle.Regular);
				}
				//Set the text of the boxes.
				textMonth0.Text=month0Span.ToStringHmm();
				textMonth1.Text=month1Span.ToStringHmm();
				textMonth2.Text=month2Span.ToStringHmm();
				textMonth3.Text=month3Span.ToStringHmm();
				if(avgCount>0) {
					int test=(int)totalSpan.TotalMinutes/avgCount;
					textMonthAvg.Text=new TimeSpan(0,(int)totalSpan.TotalMinutes/avgCount,0).ToStringHmm();
				}
				else {
					textMonthAvg.Text="";
				}
			}
		}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:101,代码来源:ContrChart.cs

示例3: GetGridForPrinting


//.........这里部分代码省略.........
					//if this is the last entry for a given date
					if(i==mergedAL.Count-1//if this is the last row
						|| GetDateForRow(i+1,mergedAL) != curDate)//or the next row is a different date
					{
						row.Cells.Add(ClockEvents.Format(daySpan));
						daySpan=new TimeSpan(0);
					}
					else{//not the last entry for the day
						row.Cells.Add("");
					}
					//Weekly-------------------------------------
					weeklyTotals[i]=weekSpan;
					//if this is the last entry for a given week
					if(i==mergedAL.Count-1//if this is the last row 
						|| cal.GetWeekOfYear(GetDateForRow(i+1,mergedAL),rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek))//or the next row has a
						!= cal.GetWeekOfYear(clock.TimeDisplayed1.Date,rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek)))//different week of year
					{
						row.Cells.Add(ClockEvents.Format(weekSpan));
						weekSpan=new TimeSpan(0);
					}
					else {
						//row.Cells.Add(ClockEvents.Format(weekSpan));
						row.Cells.Add("");
					}
					//Note-----------------------------------------
					row.Cells.Add(clock.Note);
				}
				//adjustment row--------------------------------------------------------------------------------------
				else if(type==typeof(TimeAdjust)){
					adjust=(TimeAdjust)mergedAL[i];
					curDate=adjust.TimeEntry.Date;
					if(curDate==previousDate){
						row.Cells.Add("");
						row.Cells.Add("");
					}
					else{
						row.Cells.Add(curDate.ToShortDateString());
						row.Cells.Add(curDate.DayOfWeek.ToString());
					}
					//altered--------------------------------------
					//Deprecated
					//status--------------------------------------
					//row.Cells.Add("");//3
					//in/out------------------------------------------
					row.Cells.Add("");//4
					//time-----------------------------
					row.Cells.Add(adjust.TimeEntry.ToShortTimeString());//5
					//total-------------------------------
					row.Cells.Add("");//
					//Adjust------------------------------
					daySpan+=adjust.RegHours;//might be negative
					weekSpan+=adjust.RegHours;
					periodSpan+=adjust.RegHours;
					row.Cells.Add(ClockEvents.Format(adjust.RegHours));//6
					//Rate2-------------------------------
					row.Cells.Add("");//
					//Overtime------------------------------
					otspan+=adjust.OTimeHours;
					row.Cells.Add(ClockEvents.Format(adjust.OTimeHours));//7
					//Daily-----------------------------------
					//if this is the last entry for a given date
					if(i==mergedAL.Count-1//if this is the last row
						|| GetDateForRow(i+1,mergedAL) != curDate)//or the next row is a different date
					{
						row.Cells.Add(ClockEvents.Format(daySpan));//
						daySpan=new TimeSpan(0);
					}
					else{
						row.Cells.Add("");
					}
					//Weekly-------------------------------------
					weeklyTotals[i]=weekSpan;
					//if this is the last entry for a given week
					if(i==mergedAL.Count-1//if this is the last row 
						|| cal.GetWeekOfYear(GetDateForRow(i+1,mergedAL),rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek))//or the next row has a
						!= cal.GetWeekOfYear(adjust.TimeEntry.Date,rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek)))//different week of year
					{
						ODGridCell cell=new ODGridCell(ClockEvents.Format(weekSpan));
						cell.ColorText=Color.Black;
						row.Cells.Add(cell);
						weekSpan=new TimeSpan(0);
					}
					else {
						row.Cells.Add("");
					}
					//Note-----------------------------------------
					row.Cells.Add("(Adjust)"+adjust.Note);//used to indicate adjust rows.
					row.Cells[row.Cells.Count-1].ColorText=Color.Red;
				}
				gridTimeCard.Rows.Add(row);
			}
			gridTimeCard.EndUpdate();
			totalTime=periodSpan.ToStringHmm();
			overTime=otspan.ToStringHmm();
			rate2Time=rate2span.ToStringHmm();
			totalTime2=periodSpan.TotalHours.ToString("n");
			overTime2=otspan.TotalHours.ToString("n");
			rate2Time2=rate2span.TotalHours.ToString("n");
			return gridTimeCard;
		}
开发者ID:mnisl,项目名称:OD,代码行数:101,代码来源:FormTimeCardManage.cs

示例4: Format

		///<summary>-hh:mm or -hh.mm, depending on the pref.TimeCardsUseDecimalInsteadOfColon.  Blank if zero.</summary>
		public static string Format(TimeSpan span) {
			if(PrefC.GetBool(PrefName.TimeCardsUseDecimalInsteadOfColon)){
				if(span==TimeSpan.Zero){
					return "";
				}
				return span.TotalHours.ToString("n");
			}
			else{
				return span.ToStringHmm();//blank if zero
			}
		}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:12,代码来源:ClockEvents.cs


注:本文中的System.TimeSpan.ToStringHmm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。