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


C# DateTime类代码示例

本文整理汇总了C#中DateTime的典型用法代码示例。如果您正苦于以下问题:C# DateTime类的具体用法?C# DateTime怎么用?C# DateTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: WithRefsWithReturn

 public object WithRefsWithReturn(
     ref string param1,
     ref int param2,
     ref short param3,
     ref long param4,
     ref uint param5,
     ref ushort param6,
     ref ulong param7,
     ref bool param8,
     ref double param9,
     ref decimal param10,
     ref int? param11,
     ref object param12,
     ref char param13,
     ref DateTime param14,
     ref Single param15,
     ref IntPtr param16,
     ref UInt16 param17,
     ref UInt32 param18,
     ref UInt64 param19,
     ref UIntPtr param20
     )
 {
     throw new Exception("Foo");
 }
开发者ID:vlaci,项目名称:Anotar,代码行数:25,代码来源:OnException.cs

示例2: getPatient

 /// <summary>
 /// ดึงรายชื่อพนักงานตามเงื่อนไขที่กำหนด เพื่อนำไปแสดงบนหน้า ConvertByPayor
 /// </summary>
 /// <param name="doeFrom"></param>
 /// <param name="doeTo"></param>
 /// <param name="payor"></param>
 /// <returns></returns>
 public DataTable getPatient(DateTime doeFrom,DateTime doeTo,string payor,string mobileStatus)
 {
     System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
     #region Variable
     var dt = new DataTable();
     var strSQL = new StringBuilder();
     var clsSQL = new clsSQLNative();
     #endregion
     #region Procedure
     #region SQLQuery
     strSQL.Append("SELECT ");
     strSQL.Append("No,HN,PreName,Name,LastName,DOE,Payor,SyncWhen,'0' IsConvertPreOrder ");
     strSQL.Append("FROM ");
     strSQL.Append("Patient P ");
     strSQL.Append("WHERE ");
     strSQL.Append("(DOE BETWEEN '" + doeFrom.ToString("yyyy-MM-dd HH:mm") + "' AND '" + doeTo.ToString("yyyy-MM-dd HH:mm") + "') ");
     if(payor!="" && payor.ToLower() != "null")
     {
         strSQL.Append("AND Payor='"+payor+"' ");
     }
     if (mobileStatus == "NotRegister")
     {
         strSQL.Append("AND SyncStatus!='1' ");
     }
     else if (mobileStatus == "Register")
     {
         strSQL.Append("AND SyncStatus='1' ");
     }
     strSQL.Append("ORDER BY ");
     strSQL.Append("No;");
     #endregion
     dt = clsSQL.Bind(strSQL.ToString(), clsSQLNative.DBType.SQLServer, "MobieConnect");
     #endregion
     return dt;
 }
开发者ID:oofdui,项目名称:ContactCheckup-MassConvert,代码行数:42,代码来源:clsTempData.cs

示例3: OnTick

	void OnTick(object sender, EventArgs e)
	{
		Ped player = Game.Player.Character;

		if (Game.IsControlPressed(2, Control.VehicleExit) && DateTime.Now > this.mLastExit && player.IsInVehicle())
		{
			Wait(250);

			Vehicle vehicle = player.CurrentVehicle;
			bool isDriver = vehicle.GetPedOnSeat(VehicleSeat.Driver) == player;

			if (Game.IsControlPressed(2, Control.VehicleExit))
			{
				player.Task.LeaveVehicle(vehicle, true);
			}
			else
			{
				player.Task.LeaveVehicle(vehicle, false);

				Wait(0);

				if (isDriver)
				{
					vehicle.EngineRunning = true;
				}
			}

			this.mLastExit = DateTime.Now + TimeSpan.FromMilliseconds(2000);
		}
	}
开发者ID:CWMlolzlz,项目名称:scripthookvdotnet,代码行数:30,代码来源:ExitVehicle.cs

示例4: TryParse

        /// <summary>
        /// Tries to parse a string to a DateTime.
        /// </summary>
        /// <param name="text">The text that should be parsed.</param>
        /// <param name="culture">The culture being used.</param>
        /// <param name="result">The parsed DateTime.</param>
        /// <returns>
        /// True if the parse was successful, false if it was not.
        /// </returns>
        /// <remarks>The parsing is culture insensitive. A user can type 8p to
        /// indicate 20:00:00, or 20.</remarks>
        public override bool TryParse(string text, CultureInfo culture, out DateTime? result)
        {
            Match match = exp.Match(text);

            if (match.Success)
            {
                bool pm = text.Contains("p", StringComparison.OrdinalIgnoreCase);

                result = null;

                int hours = int.Parse(match.Groups["hours"].Value, culture);
                if (hours > 23)
                {
                    return false;
                }
                int minutes = match.Groups["minutes"].Success && match.Groups["minutes"].Value.Length > 0 ? int.Parse(match.Groups["minutes"].Value, culture) : 0;
                if (minutes > 59)
                {
                    return false;
                }
                int seconds = match.Groups["seconds"].Success && match.Groups["seconds"].Value.Length > 0 ? int.Parse(match.Groups["seconds"].Value, culture) : 0;
                if (seconds > 59)
                {
                    return false;
                }

                result = DateTime.Now.Date.AddHours(hours).AddMinutes(minutes).AddSeconds(seconds);
                result = result.Value.AddHours(pm && hours < 12 ? 12 : 0);
                return true;
            }
            result = null;
            return false;
        }
开发者ID:modulexcite,项目名称:SilverlightToolkit,代码行数:44,代码来源:CatchallTimeParser.cs

示例5: DiscardDayTime

 public static DateTime DiscardDayTime(DateTime d)
 {
     int year = d.Year;
     int month = d.Month;
     DateTime newD = new DateTime(year, month, 1, 0, 0, 0);
     return newD;
 }
开发者ID:dfr0,项目名称:moon,代码行数:7,代码来源:DateTimeHelper.cs

示例6: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["m"] != null)
         {
             try
             {
                 ShowDate = ShowDate.AddMonths(Int32.Parse(Request.QueryString["m"]));
             }
             catch
             {
                 // ignore invalid 'm' parameter -- show current month
             }
         }
         ddMonth.Items.Add(new ListItem(System.DateTime.Now.ToString("MMMM yyyy"), "0"));
         ddMonth.Items.Add(new ListItem(System.DateTime.Now.AddMonths(-1).ToString("MMMM yyyy"), "-1"));
         if (Request.QueryString["m"] != null)
             ddMonth.SelectedValue = Request.QueryString["m"];
     }
     else
     {
         ErrorMessageLabel.Visible = false;
         GridView1.Visible = true;
     }
 }
开发者ID:chathamadmin,项目名称:NCDSS-DaySheets,代码行数:26,代码来源:review.aspx.cs

示例7: SetInitInputTime

 private void SetInitInputTime(DateTime time)
 {
     Configuration cfg = WebConfigurationManager.OpenWebConfiguration("~");
     cfg.AppSettings.Settings[theKeyName].Value = time.ToString();
     cfg.Save();
     Label1.Text = "初始录入结束时间已设置为" + time.ToString();
 }
开发者ID:uwitec,项目名称:yxwz,代码行数:7,代码来源:InitInputSetting.aspx.cs

示例8: ddlYear_SelectedIndexChanged

 protected void ddlYear_SelectedIndexChanged(object sender, EventArgs e)
 {
     DateTime newday = new DateTime(int.Parse(ddlYear.SelectedValue),int.Parse(ddlMonth.SelectedValue),1);
     string querystring = this.Page.Request.QueryString.ToString();
     querystring = querystring.Replace("Day=" + strDay, "Day=" + newday.ToShortDateString().Replace('/', '-'));
     this.Page.Response.Redirect(this.Page.Request.Path + "?" + querystring);
 }
开发者ID:san90279,项目名称:UK_OAS,代码行数:7,代码来源:frmDateTimeViewer.aspx.cs

示例9: btnSearch_Click

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string sDate = Request.Form[txtStartDate.ID].Trim();
        string eDate = Request.Form[txtEndDate.ID].Trim();

        if (string.IsNullOrEmpty(sDate) && string.IsNullOrEmpty(eDate))
        {
            return;
        }
        else
        {
            DateTime startDate = new DateTime(1999, 1, 1);
            DateTime endDate = new DateTime(1999, 1, 1);
            if (!DateTime.TryParse(sDate, out startDate))
            {
                startDate = new DateTime(1999, 1, 1);
            }
            if (DateTime.TryParse(eDate, out endDate))
            {
                endDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59);
            }
            else
            {
                endDate = new DateTime(1999, 1, 1);
            }
            PaginationQueryResult<WrongOrder> result = WrongOrderOperation.GetWrongOrderByCompanyIdAndDate(PaginationHelper.GetCurrentPaginationQueryCondition(Request), user.CompanyId, startDate, endDate);
            rpWrongOrder.DataSource = result.Results;
            rpWrongOrder.DataBind();

            pagi.TotalCount = result.TotalCount;
        }
    }
开发者ID:sd1362168638,项目名称:XSEMS,代码行数:32,代码来源:ServiceTrack.aspx.cs

示例10: STD_CBEExam

 public STD_CBEExam(
     int cBEExamID,
     string candidateName,
     DateTime dOB, 
     string gender, 
     string regiNo, 
     string instituteName, 
     string tel, 
     string mobile, 
     string email, 
     string feesDescription, 
     string addedBy, 
     DateTime addedDate, 
     string updatedBy, 
     DateTime updatedDate, 
     int rowStatusID
     )
 {
     this.CBEExamID = cBEExamID;
     this.CandidateName = candidateName;
     this.DOB = dOB;
     this.Gender = gender;
     this.RegiNo = regiNo;
     this.InstituteName = instituteName;
     this.Tel = tel;
     this.Mobile = mobile;
     this.Email = email;
     this.FeesDescription = feesDescription;
     this.AddedBy = addedBy;
     this.AddedDate = addedDate;
     this.UpdatedBy = updatedBy;
     this.UpdatedDate = updatedDate;
     this.RowStatusID = rowStatusID;
 }
开发者ID:anam,项目名称:mal,代码行数:34,代码来源:STD_CBEExam.cs

示例11: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        var q = Request["q"];
        var size = Request["size"];
        if (string.IsNullOrEmpty(size)) size = "10";
        var trangThai = Request["TrangThai"];

        Ngay = Request["Ngay"];
        var url = string.Format("?q={0}&size={1}&TrangThai={2}&Ngay={3}&", q, size, trangThai, Ngay) + "{1}={0}";
        var tuNgay = "";
        var denNgay = "";
        if (!string.IsNullOrEmpty(Ngay))
        {
            Ngay = Server.UrlDecode(Ngay);
            var d = Convert.ToDateTime(Ngay, new CultureInfo("Vi-vn"));
            tuNgay = new DateTime(d.Year, d.Month, d.Day).AddDays(-1).ToString("yyyy-MM-dd");
            denNgay = new DateTime(d.Year, d.Month, d.Day).AddDays(1).ToString("yyyy-MM-dd");
        }

        using (var con = DAL.con())
        {

            var pg =
                PhieuDichVuDal.pagerTdToc(con, url, false, "PDV_Ma desc", q, Convert.ToInt32(size), trangThai
                , Security.UserId.ToString(), tuNgay, denNgay);
            List.List = pg.List;
            paging = pg.Paging;

        }
    }
开发者ID:nhatkycon,项目名称:AoCuoiHongNhung,代码行数:30,代码来源:List-Toc.aspx.cs

示例12: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("Verify DateTime.Hour property when DateTime instance's hour is assigned...");

        try
        {
            TestLibrary.Utilities.CurrentCulture = new CultureInfo("");
            DateTime myDateTime = new DateTime(0978, 08, 29, 03, 00, 00);
            int hour = myDateTime.Hour;

            if (hour != 3)
            {
                TestLibrary.TestFramework.LogError("001","The hour is not correct!");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002","Unexpected exception occurs: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:27,代码来源:datetimehour.cs

示例13: PosTest2

    public bool PosTest2()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("Verify DateTime.Hour property When DateTime instance is only assigned year month and day...");

        try
        {
            TestLibrary.Utilities.CurrentCulture = new CultureInfo("");
            DateTime myDateTime = new DateTime(1978,08,29);
            int hour = myDateTime.Hour;

            if (hour != 0)
            {
                TestLibrary.TestFramework.LogError("003","The hour is not zero when no value is assigned at init time!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("", "");
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:26,代码来源:datetimehour.cs

示例14: InitEvent

 /// <summary>
 /// Récupère la liste des évenements
 /// </summary>
 /// <param name="date"></param>
 /// <param name="controler"></param>
 public async void InitEvent(DateTime date, EventControler controler)
 {
     Controler = controler;
     List<GoogleCalendar.Data.Event> events = await Controler.GetAllEvents();
     UpdateEvent(date, events);
     
 }
开发者ID:Delvius,项目名称:KIEPresentationV2,代码行数:12,代码来源:WeekCalendar.xaml.cs

示例15: WeekCalendar

 public WeekCalendar(DateTime date)
 {
     Date = date;
     this.InitializeComponent();
     Canvas = new Canvas[24, 7];
     initBorder();
 }
开发者ID:Delvius,项目名称:KIEPresentationV2,代码行数:7,代码来源:WeekCalendar.xaml.cs


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