本文整理匯總了C#中System.DateTime.GetFullYear方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTime.GetFullYear方法的具體用法?C# DateTime.GetFullYear怎麽用?C# DateTime.GetFullYear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.DateTime
的用法示例。
在下文中一共展示了DateTime.GetFullYear方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: YMDConstructorWorks
public void YMDConstructorWorks()
{
var dt = new DateTime(2011, 7, 12);
Assert.AreEqual(dt.GetFullYear(), 2011);
Assert.AreEqual(dt.GetMonth(), 7);
Assert.AreEqual(dt.GetDate(), 12);
}
示例2: StringConstructorWorks
public void StringConstructorWorks()
{
var dt = new DateTime("Aug 12, 2012");
Assert.AreEqual(dt.GetFullYear(), 2012);
Assert.AreEqual(dt.GetMonth(), 8);
Assert.AreEqual(dt.GetDate(), 12);
}
示例3: YMDHNConstructorWorks
public void YMDHNConstructorWorks() {
var dt = new DateTime(2011, 7, 12, 13, 42);
Assert.AreEqual(dt.GetFullYear(), 2011);
Assert.AreEqual(dt.GetMonth(), 7);
Assert.AreEqual(dt.GetDate(), 12);
Assert.AreEqual(dt.GetHours(), 13);
Assert.AreEqual(dt.GetMinutes(), 42);
}
示例4: MillisecondSinceEpochConstructorWorks
public void MillisecondSinceEpochConstructorWorks()
{
var dt = new DateTime(1440L * 60 * 500 * 1000);
Assert.AreEqual(dt.GetFullYear(), 1971);
}
示例5: DefaultConstructorReturnsTodaysDate
public void DefaultConstructorReturnsTodaysDate()
{
var dt = new DateTime();
Assert.True(dt.GetFullYear() > 2011);
}
示例6: GetFullYearWorks
public void GetFullYearWorks()
{
var dt = new DateTime(2011, 7, 12, 13, 42, 56, 345);
Assert.AreEqual(dt.GetFullYear(), 2011);
}
示例7: ToLocalWorks
public void ToLocalWorks()
{
var UTC = new DateTime(2011, 7, 12, 13, 42, 56, 345);
var dt = UTC.ToLocalTime();
Assert.AreEqual(dt.GetUtcFullYear(), UTC.GetFullYear());
Assert.AreEqual(dt.GetUtcMonth(), UTC.GetMonth());
Assert.AreEqual(dt.GetUtcDate(), UTC.GetDate());
Assert.AreEqual(dt.GetUtcHours(), UTC.GetHours());
Assert.AreEqual(dt.GetUtcMinutes(), UTC.GetMinutes());
Assert.AreEqual(dt.GetUtcSeconds(), UTC.GetSeconds());
Assert.AreEqual(dt.GetUtcMilliseconds(), UTC.GetMilliseconds());
}
示例8: noFacebookSignup2SaveClick
void noFacebookSignup2SaveClick(DomEvent e)
{
e.PreventDefault();
if (AsyncInProgress)
return;
View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "";
#region Check name
if (View.Connect_LoggedOut_NoFacebook_SignUp2_FirstNameTextbox.Value.Length == 0)
{
View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Enter your first name";
return;
}
if (View.Connect_LoggedOut_NoFacebook_SignUp2_LastNameTextbox.Value.Length == 0)
{
View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Enter your last name";
return;
}
if (View.Connect_LoggedOut_NoFacebook_SignUp2_FirstNameTextbox.Value.Length > 20)
{
View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "First name is too long";
return;
}
if (View.Connect_LoggedOut_NoFacebook_SignUp2_LastNameTextbox.Value.Length > 20)
{
View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Last name is too long";
return;
}
#endregion
#region Check nickname
if (View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox.Value.Length == 0)
{
View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Enter a nickname";
return;
}
if (View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox.Value.Length < 2)
{
View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Nickname must be longer";
return;
}
if (View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox.Value.Length > 20)
{
View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Nickname is too long";
return;
}
#endregion
#region Check date of birth
if (int.ParseInvariant(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthYearDropDown.Value) < 0 ||
int.ParseInvariant(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthMonthDropDown.Value) < 0 ||
int.ParseInvariant(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthDayDropDown.Value) < 0)
{
View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Enter your date of birth";
return;
}
DateTime d = new DateTime();
d.SetFullYear(int.ParseInvariant(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthYearDropDown.Value));
d.SetMonth(int.ParseInvariant(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthMonthDropDown.Value));
d.SetDate(int.ParseInvariant(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthDayDropDown.Value));
if (d.GetFullYear() != int.ParseInvariant(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthYearDropDown.Value) ||
d.GetMonth() != int.ParseInvariant(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthMonthDropDown.Value) ||
d.GetDate() != int.ParseInvariant(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthDayDropDown.Value))
{
View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Check your date of birth";
return;
}
#endregion
#region Check sex
if (!View.Connect_LoggedOut_NoFacebook_SignUp2_SexMaleRadio.Checked && !View.Connect_LoggedOut_NoFacebook_SignUp2_SexFemaleRadio.Checked)
{
View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Enter your sex";
return;
}
#endregion
#region Check nickname
int thisAsyncOperation = RegisterStartAsync("Checking nickname...");
Server.GetUniqueNickName(
View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox.Value,
NoFacebookSignUp2PanelLoginUsrK,
new Response(
delegate(Dictionary response)
{
if (RegisterEndAsync(thisAsyncOperation))
return;
if (U.isTrue(response, "Exception"))
{
showError(7, "Internal server error");
//.........這裏部分代碼省略.........
示例9: add_View_Connect_LoggedOut_NoFacebook_SignUp2Panel
DOMElement add_View_Connect_LoggedOut_NoFacebook_SignUp2Panel()
{
#region LoggedOut_NoFacebook_SignUp2Panel
string s = @"
<div id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2Panel"" class=""LoginPanel"" style=""display:none;"">
<div class=""LoginPanelInner"">
<p class=""LoginPanelTitle"">
Enter your details...
</p>
<p style=""position:relative; height:25px; line-height:25px;"">
Real name:
<input id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_FirstNameTextbox"" type=""text"" style=""padding-left:5px; height:20px; left:140px; top:0px; position:absolute; width:100px; height:25px; line-height:25px;"" />
<input id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_LastNameTextbox"" type=""text"" style=""padding-left:5px; height:20px; left:250px; top:0px; position:absolute; width:100px; height:25px; line-height:25px;"" />
</p>
<p style=""position:relative; height:25px; line-height:25px;"">
Nickname:
<input id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox"" type=""text"" style=""padding-left:5px; height:20px; left:140px; top:0px; position:absolute; width:210px; height:25px; line-height:25px;"" />
</p>
<p style=""position:relative; height:25px; line-height:25px;"">
Date of birth:
<span style=""left:140px; top:0px; position:absolute;"">
<select id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthDayDropDown"" class=""xui-state-default ui-corner-all"" style=""padding-left:5px; height:25px; line-height:25px;""></select>
<select id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthMonthDropDown"" class=""xui-state-default ui-corner-all"" style=""padding-left:5px; height:25px; line-height:25px;""></select>
<select id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthYearDropDown"" class=""xui-state-default ui-corner-all"" style=""padding-left:5px; height:25px; line-height:25px;""></select>
</span>
</p>
<p style=""position:relative; height:25px; line-height:25px;"">
Sex:
<span style=""left:140px; top:0px; position:absolute;"">
<input id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_SexMaleRadio"" type=""radio"" name=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp1_Sex"" />
<label for=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_SexMaleRadio""> Male</label>
<input id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_SexFemaleRadio"" type=""radio"" name=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp1_Sex"" />
<label for=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_SexFemaleRadio""> Female</label>
</span>
</p>
<p style=""position:relative; height:25px; line-height:25px;"">
<button id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_SaveButton"" class=""ui-state-default ui-corner-all Pointer BigButton"" style=""left:140px; top:0px; position:absolute; width:50px;"">Save</button>
<span id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel"" class=""ForegroundAttentionRed"" style=""left:200px; position:absolute; font-weight:bold; top:7px;""></span>
</p>
</div>
<p style=""position:relative;"">
<button id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_BackButton"" class=""ui-state-default ui-corner-all Pointer SmallButton"" style=""float:left; position:absolute; left:0px;"">Back</button>
<button id=""{ClientID}Connect_LoggedOut_NoFacebook_SignUp2_CancelButton"" class=""ui-state-default ui-corner-all Pointer SmallButton"" style=""float:right;"">Cancel</button>
</p>
</div>
";
addChild(s);
#endregion
DomEvent.AddHandler(View.Connect_LoggedOut_NoFacebook_SignUp2_FirstNameTextbox, "keyup", new DomEventHandler(noFacebookSignup2NameKeyUp));
DomEvent.AddHandler(View.Connect_LoggedOut_NoFacebook_SignUp2_LastNameTextbox, "keyup", new DomEventHandler(noFacebookSignup2NameKeyUp));
DomEvent.AddHandler(View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox, "keyup", new DomEventHandler(noFacebookSignup2NicknameKeyUp));
DomEvent.AddHandler(View.Connect_LoggedOut_NoFacebook_SignUp2_CancelButton, "click", new DomEventHandler(cancelButtonClick));
DomEvent.AddHandler(View.Connect_LoggedOut_NoFacebook_SignUp2_BackButton, "click", new DomEventHandler(noFacebookSignup2BackClick));
DomEvent.AddHandler(View.Connect_LoggedOut_NoFacebook_SignUp2_SaveButton, "click", new DomEventHandler(noFacebookSignup2SaveClick));
#region add date dropdown options
if (View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthDayDropDown.Options.Length == 0)
{
addOption("-1", "", View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthDayDropDown);
for (int i = 1; i <= 31; i++)
addOption(i.ToString(), i.ToString(), View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthDayDropDown);
}
if (View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthMonthDropDown.Options.Length == 0)
{
addOption("-1", "", View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthMonthDropDown);
string[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
for (int i = 0; i < months.Length; i++)
addOption(i.ToString(), months[i], View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthMonthDropDown);
}
if (View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthYearDropDown.Options.Length == 0)
{
addOption("-1", "", View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthYearDropDown);
DateTime t = new DateTime();
int year = t.GetFullYear();
for (int i = year; i > year - 100; i--)
addOption(i.ToString(), i.ToString(), View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthYearDropDown);
}
#endregion
defaultButton(View.Connect_LoggedOut_NoFacebook_SignUp2_FirstNameTextbox, View.Connect_LoggedOut_NoFacebook_SignUp2_SaveButton);
defaultButton(View.Connect_LoggedOut_NoFacebook_SignUp2_LastNameTextbox, View.Connect_LoggedOut_NoFacebook_SignUp2_SaveButton);
defaultButton(View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox, View.Connect_LoggedOut_NoFacebook_SignUp2_SaveButton);
return View.Connect_LoggedOut_NoFacebook_SignUp2Panel;
}
示例10: DefaultConstructorWorks
public void DefaultConstructorWorks() {
var dt = new DateTime();
Assert.IsTrue(dt.GetFullYear() > 2011);
}