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


C# DateTime.IsDaylightSavingTime方法代码示例

本文整理汇总了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;
    }
开发者ID:Rts-wix,项目名称:ASP.NET-Snippets,代码行数:13,代码来源:Default.aspx.cs

示例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());
    }
开发者ID:hickford,项目名称:corefx,代码行数:10,代码来源:DateTime.cs

示例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;
        }
开发者ID:TimothyJames,项目名称:SIG-Windows8,代码行数:101,代码来源:DatePicker.xaml.cs

示例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();
            }
        }
开发者ID:niaomingjian,项目名称:corefx,代码行数:23,代码来源:Interop.NativeCrypto.cs

示例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());
    }
开发者ID:eerhardt,项目名称:corefx,代码行数:10,代码来源:DateTime.cs

示例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();
     }
开发者ID:rgatkinson,项目名称:nadir,代码行数:12,代码来源:Program.cs

示例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;
    }
开发者ID:rdterner,项目名称:coreclr,代码行数:25,代码来源:datetimeisdaylightsavingtime.cs

示例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;
    }
开发者ID:rdterner,项目名称:coreclr,代码行数:65,代码来源:datetimeisdaylightsavingtime.cs

示例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;
 }
开发者ID:rdterner,项目名称:coreclr,代码行数:7,代码来源:datetimeisdaylightsavingtime.cs

示例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;
 }
开发者ID:40a,项目名称:PowerShell,代码行数:11,代码来源:CorePsPlatform.cs


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