本文整理汇总了C#中DateTime.IsDaylightSavingTime方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.IsDaylightSavingTime方法的具体用法?C# DateTime.IsDaylightSavingTime怎么用?C# DateTime.IsDaylightSavingTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime
的用法示例。
在下文中一共展示了DateTime.IsDaylightSavingTime方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: sommertid
/// <summary>
/// Er det sommertid, eller ej?
/// </summary>
/// <param name="currentDate">Angiv datoen der skal checkes</param>
/// <returns>true/false</returns>
protected static bool sommertid(DateTime currentDate)
{
bool result = false;
result = currentDate.IsDaylightSavingTime();
return result;
}
示例2: TestToday
public static void TestToday()
{
DateTime today = DateTime.Today;
DateTime now = DateTime.Now;
ValidateYearMonthDay(today, now.Year, now.Month, now.Day);
today = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, DateTimeKind.Utc);
Assert.Equal(DateTimeKind.Utc, today.Kind);
Assert.Equal(false, today.IsDaylightSavingTime());
}
示例3: loadSection
//.........这里部分代码省略.........
sectionBox.SelectionChanged -= handler;
break;
case section.third:
sectionBox = thirdSectionComboBox;
sectionText = thirdSectionTextBlock;
handler = thirdSectionComboBox_SelectionChanged;
sectionBox.SelectionChanged -= handler;
break;
}
///Clears the sectionBox before recreating
sectionBox.Items.Clear();
///Creates different items for different Date Sections
switch (kindOfDisplay)
{
case kindOfDisplay.day:
///Creates the Days for the Month ( 31 , 30 , 29 , 28 )
for (int i = 1; i <= DateTime.DaysInMonth(time.Year, time.Month); i++)
{
item = new ComboBoxItem();
///Displayes a Day with an addition Zero or not ( 8 , 08 )
if (additionalZero && i < 10)
item.Content += "0";
item.Content += i.ToString();
///marks the correct day as selected
if (i == time.Day)
item.IsSelected = true;
///Adds the item
sectionBox.Items.Add(item);
}
///Adds the Day of the Week ( Monday ... )
sectionText.Text = time.DayOfWeek.ToString();
break;
case kindOfDisplay.month:
///Creats the different Month
for (int i = 1; i <= 12; i++)
{
item = new ComboBoxItem();
///Displayes a Month with an addition Zero or not ( 8 , 08 )
if (additionalZero && i < 10)
item.Content += "0";
item.Content += i.ToString();
///marks the correct month as selected
if (i == time.Month)
item.IsSelected = true;
///Adds the item
sectionBox.Items.Add(item);
}
///Adds the Month as its long form ( January )
sectionText.Text = time.ToString("MMM");
break;
case kindOfDisplay.year:
///Creates the Yearitems
for (int i = MinYear; i <= MaxYear; i++)
{
item = new ComboBoxItem();
///Displayes a Year in two different ways ( 13 , 2013 )
if (additionalZero)
item.Content += i.ToString().Substring(3);
else
item.Content += i.ToString();
///marks the correct year as selected
if (i == time.Year)
item.IsSelected = true;
///Adds the item
sectionBox.Items.Add(item);
}
///Clears the sectionText
sectionText.Text = "";
///Adds the DayLightSaving Flag
if (DaylightSavingFlag)
{
if (time.IsDaylightSavingTime())
sectionText.Text += "S";
else
sectionText.Text += "N";
}
///Adds the Leap Year Flag if it is a LeapYear
if (LeapYearFlag && DateTime.IsLeapYear(time.Year))
sectionText.Text += " L";
break;
}
sectionBox.SelectionChanged += handler;
}
示例4: SetX509ChainVerifyTime
internal static void SetX509ChainVerifyTime(SafeX509StoreCtxHandle ctx, DateTime verifyTime)
{
// Let Unspecified mean Local, so only convert if the source was UTC.
if (verifyTime.Kind == DateTimeKind.Utc)
{
verifyTime = verifyTime.ToLocalTime();
}
int succeeded = SetX509ChainVerifyTime(
ctx,
verifyTime.Year,
verifyTime.Month,
verifyTime.Day,
verifyTime.Hour,
verifyTime.Minute,
verifyTime.Second,
verifyTime.IsDaylightSavingTime());
if (succeeded != 1)
{
throw new CryptographicException();
}
}
示例5: TestToday
public static void TestToday()
{
DateTime today = DateTime.Today;
DateTime now = DateTime.Now;
VerifyDateTime(today, now.Year, now.Month, now.Day, 0, 0, 0, 0, DateTimeKind.Local);
today = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, DateTimeKind.Utc);
Assert.Equal(DateTimeKind.Utc, today.Kind);
Assert.False(today.IsDaylightSavingTime());
}
示例6: ProgramVersionDate
string ProgramVersionDate()
{
Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
DateTime creationDate = new DateTime(2000, 1, 1).AddDays(version.Build).AddSeconds(version.Revision*2);
if (creationDate.IsDaylightSavingTime())
{
// Running on Windows 10, at least, or maybe it's just .Net 4.6, not sure, this seems
// to be take care of for us automatically.
// creationDate = creationDate.AddHours(1);
}
return creationDate.ToString("dd MMM yyyy ") + creationDate.ToShortTimeString();
}
示例7: PosTest2
public bool PosTest2()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest2: IsDaylightSavingTime should return false if corrent time is daylight time and current timezone supports daylight time when Kind is Utc");
try
{
DateTime t = new DateTime(2006, 9, 25, 3, 21, 0, 0, DateTimeKind.Utc);
if (t.IsDaylightSavingTime())
{
TestLibrary.TestFramework.LogError("002.1", "IsDaylightSavingTime returns true if corrent time is daylight time and current timezone supports daylight time when Kind is Utc");
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e);
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}
示例8: VerificationHelper
private bool VerificationHelper(DateTime t)
{
if (!TestLibrary.Utilities.IsWindows)
return MacVerificationHelper(t);
// else...
TIME_ZONE_INFORMATION lpTimeZoneInformation = new TIME_ZONE_INFORMATION();
uint callVal = GetTimeZoneInformation(ref lpTimeZoneInformation);
if (TIME_ZONE_ID_INVALID == callVal)
{
throw new Exception("WINAPI set error = " + GetLastError());
}
bool expected = false;
if (lpTimeZoneInformation.DaylightBias != 0)
{
// This timezone have Daylight setting set
int daylightMonth = lpTimeZoneInformation.DaylightDate.wMonth;
int standardMonth = lpTimeZoneInformation.StandardDate.wMonth;
// Determine t.month is in day light time range
// In this case, daylightMonth is 4, standardMonth is 10
// so May is considered in day light time range, whereas Feruary is not
if ((daylightMonth < standardMonth) &&
((t.Month - daylightMonth) > 0) &&
((t.Month - standardMonth) < 0))
{
expected = true;
}
// Determine t.month is in day light time range
// In this case, daylightMonth is 10, standardMonth is 3
// so May is not considered in day light time range, whereas Feruary is
if ((daylightMonth > standardMonth) &&
(((t.Month - daylightMonth) > 0) ^
((t.Month - standardMonth) > 0) == false))
{
expected = true;
}
if (t.Month == lpTimeZoneInformation.DaylightDate.wMonth)
{
if (t.Day > lpTimeZoneInformation.DaylightDate.wDay)
{
expected = true;
}
}
if (t.Month == lpTimeZoneInformation.StandardDate.wMonth)
{
if (t.Day < lpTimeZoneInformation.StandardDate.wDay)
{
expected = true;
}
}
}
bool actual = t.IsDaylightSavingTime();
return expected == actual;
}
示例9: MacVerificationHelper
private bool MacVerificationHelper(DateTime t)
{
IntPtr cfTimeZoneRef = CFDateTimeTools.CFTimeZoneCopySystem();
bool osResult = CFDateTimeTools.CFTimeZoneIsDaylightSavingTime(cfTimeZoneRef, CFDateTimeTools.DateTimeToCFAbsoluteTime(t));
bool clrResult = t.IsDaylightSavingTime();
return osResult == clrResult;
}
示例10: SetDateInfoInternal
public SetDateInfoInternal(DateTime d)
{
Year = d.Year;
Month = d.Month;
Day = d.Day;
Hour = d.Hour;
Minute = d.Minute;
Second = d.Second;
Millisecond = d.Millisecond;
DST = d.IsDaylightSavingTime() ? 1 : 0;
}