本文整理汇总了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");
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例7: SetInitInputTime
private void SetInitInputTime(DateTime time)
{
Configuration cfg = WebConfigurationManager.OpenWebConfiguration("~");
cfg.AppSettings.Settings[theKeyName].Value = time.ToString();
cfg.Save();
Label1.Text = "初始录入结束时间已设置为" + time.ToString();
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例15: WeekCalendar
public WeekCalendar(DateTime date)
{
Date = date;
this.InitializeComponent();
Canvas = new Canvas[24, 7];
initBorder();
}